diff --git a/wagtail/admin/templates/wagtailadmin/home/workflow_objects_to_moderate.html b/wagtail/admin/templates/wagtailadmin/home/workflow_objects_to_moderate.html index efa4ccf936..d8275b710c 100644 --- a/wagtail/admin/templates/wagtailadmin/home/workflow_objects_to_moderate.html +++ b/wagtail/admin/templates/wagtailadmin/home/workflow_objects_to_moderate.html @@ -16,41 +16,45 @@ - {% for task_state, actions, workflow_tasks in states %} - {% with task_state.revision as revision %} - {% page_permissions revision.content_object as page_perms %} + {% for state in states %} + {% with revision=state.task_state.revision obj=state.obj task_state=state.task_state actions=state.actions workflow_tasks=state.workflow_tasks %} + {% is_page obj as is_page %} + {% if is_page %} + {% page_permissions obj as page_perms %} + {% endif %}
- {% if page_perms.can_edit %} - {{ revision.content_object.specific_deferred.get_admin_display_title }} + {% admin_edit_url obj as edit_url %} + {% if page_perms.can_edit or not is_page and edit_url %} + {% latest_str obj %} {% else %} - {{ revision.content_object.specific_deferred.get_admin_display_title }} + {% latest_str obj %} {% endif %} {% i18n_enabled as show_locale_labels %} - {% if show_locale_labels and revision.content_object.locale_id %} - {% locale_label_from_id revision.content_object.locale_id as locale_label %} + {% if show_locale_labels and obj.locale_id %} + {% locale_label_from_id obj.locale_id as locale_label %} {{ locale_label }} {% endif %} - {% include "wagtailadmin/pages/listing/_privacy_indicator.html" with page=revision.content_object %} - {% include "wagtailadmin/pages/listing/_locked_indicator.html" with page=revision.content_object %} + {% include "wagtailadmin/pages/listing/_privacy_indicator.html" with page=obj %} + {% include "wagtailadmin/pages/listing/_locked_indicator.html" with page=obj %}
{% if actions %} diff --git a/wagtail/admin/views/home.py b/wagtail/admin/views/home.py index e9babde809..f49a1c73dd 100644 --- a/wagtail/admin/views/home.py +++ b/wagtail/admin/views/home.py @@ -163,30 +163,47 @@ class WorkflowObjectsToModeratePanel(Component): def get_context_data(self, parent_context): request = parent_context["request"] context = super().get_context_data(parent_context) - if getattr(settings, "WAGTAIL_WORKFLOW_ENABLED", True): - states = ( - TaskState.objects.reviewable_by(request.user) - .select_related( - "revision", - "task", - "revision__user", - ) - .order_by("-started_at") - ) - context["states"] = [ - ( - state, - state.task.specific.get_actions( - obj=state.revision.content_object, user=request.user - ), - state.workflow_state.all_tasks_with_status(), - ) - for state in states - ] - else: - context["states"] = [] + context["states"] = [] context["request"] = request context["csrf_token"] = parent_context["csrf_token"] + + if not getattr(settings, "WAGTAIL_WORKFLOW_ENABLED", True): + return context + + states = ( + TaskState.objects.reviewable_by(request.user) + .select_related( + "revision", + "task", + "revision__user", + ) + .order_by("-started_at") + ) + for state in states: + obj = state.revision.content_object + actions = state.task.specific.get_actions(obj, request.user) + workflow_tasks = state.workflow_state.all_tasks_with_status() + + url_name_prefix = "wagtailadmin_pages" + if not isinstance(obj, Page): + url_name_prefix = obj.get_admin_url_namespace() + + workflow_action_url_name = f"{url_name_prefix}:workflow_action" + workflow_preview_url_name = None + if getattr(obj, "is_previewable", False): + workflow_preview_url_name = f"{url_name_prefix}:workflow_preview" + + context["states"].append( + { + "obj": obj, + "task_state": state, + "actions": actions, + "workflow_tasks": workflow_tasks, + "workflow_action_url_name": workflow_action_url_name, + "workflow_preview_url_name": workflow_preview_url_name, + } + ) + return context