From 8487742df8eb32133116aef830c0a2a9a90d3e3e Mon Sep 17 00:00:00 2001 From: Karl Hobley Date: Tue, 18 Feb 2020 12:12:16 +0000 Subject: [PATCH] Remove unnecessary workflow_name/task_name variables --- .../wagtailadmin/shared/workflow_status.html | 15 ++++++++++++--- wagtail/admin/views/pages.py | 10 ++-------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/wagtail/admin/templates/wagtailadmin/shared/workflow_status.html b/wagtail/admin/templates/wagtailadmin/shared/workflow_status.html index e3b775c92e..3ba72f78bc 100644 --- a/wagtail/admin/templates/wagtailadmin/shared/workflow_status.html +++ b/wagtail/admin/templates/wagtailadmin/shared/workflow_status.html @@ -1,10 +1,15 @@ {% load wagtailui_tags i18n %} {% if workflow_tasks %} -

{{ workflow_name }}

+ {% with current_task_state.workflow_state as current_workflow_state %} + {% with current_workflow_state.workflow as workflow %} + {% with current_task_state.task as task %} + +

{{ workflow.name }}

+ {% if current_task_number %} - {% blocktrans %} Task {{ current_task_number }} of {{ workflow_tasks.count }}{% endblocktrans %}: {{ task_name }} + {% blocktrans %} Task {{ current_task_number }} of {{ workflow_tasks.count }}{% endblocktrans %}: {{ task.name }} {% else %} - {% trans 'Task' %}: {{ task_name }} + {% trans 'Task' %}: {{ task.name }} {% endif %}
{% trans 'Approved task' as approved_title %} @@ -17,4 +22,8 @@ {% endif %} {% endfor %}
+ + {% endwith %} + {% endwith %} + {% endwith %} {% endif %} diff --git a/wagtail/admin/views/pages.py b/wagtail/admin/views/pages.py index 56f90b9fb8..13bd74a1d6 100644 --- a/wagtail/admin/views/pages.py +++ b/wagtail/admin/views/pages.py @@ -413,8 +413,6 @@ def edit(request, page_id): workflow_tasks = [] workflow_state = page.current_workflow_state - workflow_name = '' - task_name = '' current_task_number = None if workflow_state: workflow = workflow_state.workflow @@ -424,8 +422,6 @@ def edit(request, page_id): except WorkflowTask.DoesNotExist: # The Task has been removed from the Workflow pass - task_name = task.name - workflow_name = workflow.name workflow_tasks = workflow_state.all_tasks_with_status() @@ -447,9 +443,9 @@ def edit(request, page_id): # If only one task in workflow, show simple message workflow_info = _("This page is currently awaiting moderation") elif current_task_number: - workflow_info = format_html(_("Page '{}' is on Task {} of {}: '{}' in Workflow '{}'. "), page.get_admin_display_title(), current_task_number, workflow_tasks.count(), task_name, workflow_name) + workflow_info = format_html(_("Page '{}' is on Task {} of {}: '{}' in Workflow '{}'. "), page.get_admin_display_title(), current_task_number, workflow_tasks.count(), task.name, workflow.name) else: - workflow_info = format_html(_("Page '{}' is on Task '{}' in Workflow '{}'. "), page.get_admin_display_title(), current_task_number, workflow_tasks.count(), task_name, workflow_name) + workflow_info = format_html(_("Page '{}' is on Task '{}' in Workflow '{}'. "), page.get_admin_display_title(), current_task_number, workflow_tasks.count(), task.name, workflow.name) if task_has_been_approved and getattr(settings, 'WAGTAIL_WORKFLOW_REQUIRE_REAPPROVAL_ON_EDIT', True): messages.warning(request, mark_safe(workflow_info + _("Editing this Page will cause completed Tasks to need re-approval.")), buttons=buttons, extra_tags="workflow") @@ -672,8 +668,6 @@ def edit(request, page_id): 'current_task_state': page.current_workflow_task_state, 'workflow_tasks': workflow_tasks, 'current_task_number': current_task_number, - 'task_name': task_name, - 'workflow_name': workflow_name, })