mirror of
https://github.com/wagtail/wagtail.git
synced 2024-12-01 11:41:20 +01:00
Add back button from add_to_page view
This commit is contained in:
parent
95d6d2a293
commit
8c7a45dd48
@ -24,7 +24,7 @@
|
||||
{% include "wagtailadmin/shared/header.html" %}
|
||||
{% endblock %}
|
||||
|
||||
<form action="{% url 'wagtailadmin_workflows:add_to_page' workflow.id %}" method="POST" enctype="multipart/form-data" novalidate>
|
||||
<form action="{% url 'wagtailadmin_workflows:add_to_page' workflow.pk %}" method="POST" enctype="multipart/form-data" novalidate>
|
||||
{% csrf_token %}
|
||||
<div class="nice-padding">
|
||||
<ul class="fields">
|
||||
@ -51,7 +51,7 @@
|
||||
<a href="." class="button button-secondary">{% trans 'Cancel' %}</a>
|
||||
{% else %}
|
||||
<button type="submit" class="button">{% trans 'Add to Page' %}</button>
|
||||
<a href="{"
|
||||
<a href="{% url 'wagtailadmin_workflows:edit' workflow.pk %}" class="button button-secondary">{% trans 'Return to Workflow' %}</a>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
|
@ -100,42 +100,6 @@ class Edit(EditView):
|
||||
return context
|
||||
|
||||
|
||||
def edit(request, pk):
|
||||
if not request.user.is_superuser:
|
||||
raise PermissionDenied
|
||||
workflow = get_object_or_404(Workflow, pk=pk)
|
||||
edit_handler = Workflow.get_edit_handler()
|
||||
edit_handler = edit_handler.bind_to(request=request, instance=workflow)
|
||||
form_class = edit_handler.get_form_class()
|
||||
pages = Page.objects.filter(workflowpage__workflow=workflow)
|
||||
|
||||
next_url = get_valid_next_url_from_request(request)
|
||||
|
||||
if request.method == 'POST':
|
||||
form = form_class(request.POST, request.FILES, instance=workflow)
|
||||
if form.is_valid():
|
||||
workflow = form.save()
|
||||
else:
|
||||
form = form_class(instance=workflow)
|
||||
|
||||
edit_handler = edit_handler.bind_to(form=form)
|
||||
page_number = int(request.GET.get('p', 1))
|
||||
page = pages.paginator.page(page_number)
|
||||
|
||||
|
||||
return render(request, 'wagtailadmin/workflows/edit.html', {
|
||||
'edit_handler': edit_handler,
|
||||
'workflow': workflow,
|
||||
'form': form,
|
||||
'icon': 'placeholder',
|
||||
'title': _("Workflows"),
|
||||
'subtitle': _("Edit Workflow"),
|
||||
'next': next_url,
|
||||
'pages': page,
|
||||
'paginator': pages.paginator,
|
||||
})
|
||||
|
||||
|
||||
@require_POST
|
||||
def remove_workflow(request, page_pk, workflow_pk=None):
|
||||
# Remove a workflow from a page (specifically a single workflow if workflow_pk is set)
|
||||
@ -199,6 +163,7 @@ def add_to_page(request, workflow_pk):
|
||||
form = form_class(request.POST, request.FILES)
|
||||
if form.is_valid():
|
||||
form.save()
|
||||
messages.success(request, _("Workflow '{0}' added to Page '{1}'.").format(workflow, form.cleaned_data['page']))
|
||||
form = form_class(initial={'workflow': workflow.pk, 'overwrite_existing': False})
|
||||
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user