From 3e42c2c8dba33a5cfee259680ab5f1147c7ce163 Mon Sep 17 00:00:00 2001 From: Lauren Qurashi Date: Fri, 27 Sep 2024 15:31:30 +0100 Subject: [PATCH 01/26] Add confirmation page to sync route --- measures/editors.py | 2 +- .../measures/confirm-edit-multiple.jinja | 42 +++++++++++++++++++ measures/views/wizard.py | 13 +++--- 3 files changed, 50 insertions(+), 7 deletions(-) create mode 100644 measures/jinja2/measures/confirm-edit-multiple.jinja diff --git a/measures/editors.py b/measures/editors.py index 0a55451f2..55384354d 100644 --- a/measures/editors.py +++ b/measures/editors.py @@ -113,6 +113,6 @@ def edit_measures(self) -> List["measure_models.Measure"]: workbasket=self.workbasket, ) - edited_measures.append(new_measure.id) + edited_measures.append(new_measure) return edited_measures diff --git a/measures/jinja2/measures/confirm-edit-multiple.jinja b/measures/jinja2/measures/confirm-edit-multiple.jinja new file mode 100644 index 000000000..f6ca07980 --- /dev/null +++ b/measures/jinja2/measures/confirm-edit-multiple.jinja @@ -0,0 +1,42 @@ +{% extends "layouts/confirm.jinja" %} +{% from "components/breadcrumbs.jinja" import breadcrumbs %} + +{% set page_title = "Edit measure details" %} + +{% macro panel_title(edited_measures) %} + {% if edited_measures|length > 1 %} + {{ edited_measures.0._meta.verbose_name_plural|title }} {% for m in edited_measures %}{% if not loop.last %}{{ m|string }}, {% else %}{{ m|string }} {% endif %}{% endfor %}have been edited + {% else %} + {{ edited_measures.0._meta.verbose_name|title }} {{ edited_measures.0|string }} has been edited + {% endif %} +{% endmacro %} + +{% macro panel_subtitle(created_measures) %} + This change has been added to your workbasket +{% endmacro %} + +{% block breadcrumb %} + {{ breadcrumbs(request, [ + {"text": page_title }, + ]) + }} +{% endblock %} + +{% block content %} +
+
+ {{ govukPanel({ + "titleText": panel_title(edited_measures), + "text": panel_subtitle(edited_measures), + "classes": "govuk-!-margin-bottom-7" + }) }} +

Next steps

+

To complete your task you must publish your change.

+ {{ govukButton({ + "text": "Go to workbasket summary", + "href": url("workbaskets:current-workbasket"), + "classes": "govuk-button--secondary" + }) }} +
+
+{% endblock %} \ No newline at end of file diff --git a/measures/views/wizard.py b/measures/views/wizard.py index b69b6d1b9..c81b7b72e 100644 --- a/measures/views/wizard.py +++ b/measures/views/wizard.py @@ -197,16 +197,17 @@ def sync_done(self, form_list, **kwargs): cleaned_data = self.get_all_cleaned_data() selected_measures = self.get_queryset() - self.edit_measures(selected_measures, cleaned_data) + edited_measures = self.edit_measures(selected_measures, cleaned_data) self.session_store.clear() - return redirect( - reverse( - "workbaskets:workbasket-ui-review-measures", - kwargs={"pk": self.workbasket.pk}, - ), + context = self.get_context_data( + form=None, + edited_measures=edited_measures, + **kwargs, ) + return render(self.request, "measures/confirm-edit-multiple.jinja", context) + @method_decorator(require_current_workbasket, name="dispatch") class MeasureCreateWizard( From 00cb172a7e9fd6d91523de710eab1bb8ed448ae1 Mon Sep 17 00:00:00 2001 From: Lauren Qurashi Date: Fri, 27 Sep 2024 16:14:52 +0100 Subject: [PATCH 02/26] Redirect async route to create success page --- measures/urls.py | 5 +++++ measures/views/wizard.py | 6 ++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/measures/urls.py b/measures/urls.py index 5482e0137..7e7f8c6e5 100644 --- a/measures/urls.py +++ b/measures/urls.py @@ -43,6 +43,11 @@ ), name="measure-ui-edit-multiple", ), + path( + "edit/done-async//", + views.MeasuresWizardCreateConfirm.as_view(), + name="measure-ui-edit-confirm", + ), path( "delete-multiple-measures/", views.MeasureMultipleDelete.as_view(), diff --git a/measures/views/wizard.py b/measures/views/wizard.py index c81b7b72e..df0b50a26 100644 --- a/measures/views/wizard.py +++ b/measures/views/wizard.py @@ -167,10 +167,8 @@ def async_done(self, form_list, **kwargs): measures_bulk_editor.schedule_task() return redirect( - reverse( - "workbaskets:workbasket-ui-review-measures", - kwargs={"pk": self.workbasket.pk}, - ), + "measure-ui-edit-confirm", + expected_measures_count=len(db_selected_measures), ) def edit_measures(self, selected_measures, cleaned_data): From 81b9959d89ee31df9f04b105d77bf85ff9d66f7d Mon Sep 17 00:00:00 2001 From: Lauren Qurashi Date: Fri, 4 Oct 2024 16:02:55 +0100 Subject: [PATCH 03/26] Make measures a small m --- .../jinja2/measures/confirm-create-multiple-async.jinja | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/measures/jinja2/measures/confirm-create-multiple-async.jinja b/measures/jinja2/measures/confirm-create-multiple-async.jinja index 3425becb2..43a0e4838 100644 --- a/measures/jinja2/measures/confirm-create-multiple-async.jinja +++ b/measures/jinja2/measures/confirm-create-multiple-async.jinja @@ -8,7 +8,7 @@ {% endmacro %} {% macro panel_subtitle(created_measures) %} - You can view {% if expected_measures_count > 1 %}their{% else %}its{% endif %} status on the Measures process queue page. + You can view {% if expected_measures_count > 1 %}their{% else %}its{% endif %} status on the measures process queue page. {% endmacro %} {% block breadcrumb %} @@ -37,6 +37,11 @@ "href": url("home"), "classes": "govuk-button--secondary" }) }} + {{ govukButton({ + "text": "Return to workbasket", + "href": url("workbaskets:current-workbasket"), + "classes": "govuk-button--secondary" + }) }} From de53aeeed41c1b52791b2c1c7e99550e966e61a1 Mon Sep 17 00:00:00 2001 From: Lauren Qurashi Date: Fri, 4 Oct 2024 17:41:22 +0100 Subject: [PATCH 04/26] WIP- Make edit process queue page --- common/jinja2/common/celery_queues.jinja | 5 + .../jinja2/measures/edit-process-queue.jinja | 86 +++++++++++++ measures/urls.py | 5 + measures/views/bulk_processing.py | 121 ++++++++++++++++++ 4 files changed, 217 insertions(+) create mode 100644 measures/jinja2/measures/edit-process-queue.jinja diff --git a/common/jinja2/common/celery_queues.jinja b/common/jinja2/common/celery_queues.jinja index 3be4bb057..8958d29c7 100644 --- a/common/jinja2/common/celery_queues.jinja +++ b/common/jinja2/common/celery_queues.jinja @@ -10,6 +10,11 @@ "href": url('measure-create-process-queue'), "selected": selected_tab == "measure-process-queue" }, + { + "text": "Measure edit process queue", + "href": url('measure-edit-process-queue'), + "selected": selected_tab == "measure-edit-process-queue" + }, { "text": "Rule check queue", "href": url('workbaskets:rule-check-queue'), diff --git a/measures/jinja2/measures/edit-process-queue.jinja b/measures/jinja2/measures/edit-process-queue.jinja new file mode 100644 index 000000000..8b29d5a8c --- /dev/null +++ b/measures/jinja2/measures/edit-process-queue.jinja @@ -0,0 +1,86 @@ +{% extends "common/celery_queues.jinja" %} + +{% from "macros/inline_filter_links.jinja" import inline_filter_links %} +{% from "components/table/macro.njk" import govukTable %} +{% from "components/button/macro.njk" import govukButton %} + +{% set list_include = "includes/measures/create-task-list.jinja"%} +{# Might wanna make an edit one or make this one useable by both #} + +{% set page_title = "Measures process queue" %} + + +{% block breadcrumb %} + {{ breadcrumbs( + request, + [ {"text": page_title} ], + with_workbasket=False, + ) }} +{% endblock %} + +{% set filter_links_list = [ + { + "text": "All", + "href": "?processing_state=", + "selected": selected_link == "all", + }, + { + "text": "Processing", + "href": "?processing_state=PROCESSING", + "selected": selected_link == "processing", + }, + { + "text": "Completed", + "href": "?processing_state=SUCCESSFULLY_PROCESSED", + "selected": selected_link == "completed", + }, + { + "text": "Failed", + "href": "?processing_state=FAILED_PROCESSING", + "selected": selected_link == "failed", + }, + { + "text": "Terminated", + "href": "?processing_state=CANCELLED", + "selected": selected_link == "terminated", + }, +]%} + +{% block tab_content %} +
+ +
+

{{ page_title }}

+ + +
+ +
+
+
+ +
+ {% if object_list %} + {% include list_include%} + {% else %} +

No bulk create/edit tasks with this status

+ {% endif %} +
+ +
+ {% include "includes/common/pagination.jinja" %} +
+ +
+{% endblock %} \ No newline at end of file diff --git a/measures/urls.py b/measures/urls.py index 7e7f8c6e5..be63756af 100644 --- a/measures/urls.py +++ b/measures/urls.py @@ -76,6 +76,11 @@ views.MeasuresCreateProcessQueue.as_view(), name="measure-create-process-queue", ), + path( + "edit-process-queue/", + views.MeasuresEditProcessQueue.as_view(), + name="measure-edit-process-queue", + ), path( "cancel-bulk-processor-task//", views.CancelBulkProcessorTask.as_view(), diff --git a/measures/views/bulk_processing.py b/measures/views/bulk_processing.py index d6b18e02e..cebc68a26 100644 --- a/measures/views/bulk_processing.py +++ b/measures/views/bulk_processing.py @@ -196,3 +196,124 @@ def status_tag_generator(self, task: models.MeasuresBulkCreator) -> dict: "text": "", "tag_class": "", } + + +class MeasuresEditProcessQueue( + PermissionRequiredMixin, + WithPaginationListView, +): + """UI endpoint for bulk editing Measures process queue.""" + + permission_required = [ + "common.add_trackedmodel", + "common.change_trackedmodel", + ] + template_name = "measures/edit-process-queue.jinja" + model = models.MeasuresBulkEditor + queryset = models.MeasuresBulkEditor.objects.filter( + workbasket__status=WorkflowStatus.EDITING, + ).order_by("-created_at") + filterset_class = MeasureCreateTaskFilter + + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + + context["selected_link"] = "all" + context["selected_tab"] = "measure-edit-process-queue" + processing_state = self.request.GET.get("processing_state") + + if processing_state == "PROCESSING": + context["selected_link"] = "processing" + elif processing_state == ProcessingState.CANCELLED: + context["selected_link"] = "terminated" + elif processing_state == ProcessingState.FAILED_PROCESSING: + context["selected_link"] = "failed" + elif processing_state == ProcessingState.SUCCESSFULLY_PROCESSED: + context["selected_link"] = "completed" + # Provide template access to some UI / view utility functions. + context["status_tag_generator"] = self.status_tag_generator + context["can_terminate_task"] = self.can_terminate_task + context["is_task_failed"] = self.is_task_failed + context["is_task_terminated"] = self.is_task_terminated + # Apply the TAP standard date format within the UI. + context["datetime_format"] = settings.DATETIME_FORMAT + if context["selected_link"] == "processing": + context["object_list"] = self.get_processing_queryset() + return context + + def get_processing_queryset(self): + """Returns a combined queryset of tasks either AWAITING_PROCESSING or + CURRENTLY_PROCESSING.""" + + return self.queryset.filter( + Q(processing_state=ProcessingState.AWAITING_PROCESSING) + | Q(processing_state=ProcessingState.CURRENTLY_PROCESSING), + ) + + def is_task_failed(self, task: models.MeasuresBulkCreator) -> bool: + """ + Return True if the task is in a failed state. + + Return False otherwise. + """ + + return task.processing_state == ProcessingState.FAILED_PROCESSING + + def is_task_terminated(self, task: MeasuresBulkCreator) -> bool: + """ + Return True if the task is in a cancelled state. Cancelled tasks are + surfaced as 'terminated' in the UI. + + Return False otherwise. + """ + + return task.processing_state == ProcessingState.CANCELLED + + def can_terminate_task(self, task: MeasuresBulkCreator) -> bool: + """ + Return True if a task is in a queued state and the current user is + permitted to terminate a task. + + Return False otherwise. + """ + + if ( + self.request.user.is_superuser + and task.processing_state in ProcessingState.queued_states() + ): + return True + + return False + + def status_tag_generator(self, task: models.MeasuresBulkCreator) -> dict: + """Returns a dict with text and a CSS class for a UI-friendly label for + a bulk creation task.""" + + if task.processing_state in [ + ProcessingState.CURRENTLY_PROCESSING, + ProcessingState.AWAITING_PROCESSING, + ]: + return { + "text": "Processing", + "tag_class": "tamato-badge-light-blue", + } + elif task.processing_state == ProcessingState.SUCCESSFULLY_PROCESSED: + return { + "text": "Completed", + "tag_class": "tamato-badge-light-green", + } + elif task.processing_state == ProcessingState.FAILED_PROCESSING: + return { + "text": "Failed", + "tag_class": "tamato-badge-light-red", + } + elif task.processing_state == ProcessingState.CANCELLED: + return { + "text": "Terminated", + "tag_class": "tamato-badge-light-yellow", + } + else: + return { + "text": "", + "tag_class": "", + } From f8e2bde7c68b6af90aa62ec66d9dd35373c895d8 Mon Sep 17 00:00:00 2001 From: marya Date: Thu, 10 Oct 2024 13:13:27 +0100 Subject: [PATCH 05/26] add expected measures count property to bulk editor --- measures/models/bulk_processing.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/measures/models/bulk_processing.py b/measures/models/bulk_processing.py index 908e90d98..77e1f3d1c 100644 --- a/measures/models/bulk_processing.py +++ b/measures/models/bulk_processing.py @@ -479,6 +479,10 @@ class MeasuresBulkEditor(BulkProcessor): ) """The user who submitted the task to create measures.""" + @property + def expected_measures_count(self) -> int: + return len(self.selected_measures) + def schedule_task(self) -> AsyncResult: """Implementation of base class method.""" From bc66887bd1903acd845b84a7eb1ea335f51932bc Mon Sep 17 00:00:00 2001 From: marya Date: Fri, 11 Oct 2024 16:50:46 +0100 Subject: [PATCH 06/26] Create and apply bulk edit measures processing state filter --- measures/filters.py | 11 +++++++++++ measures/views/bulk_processing.py | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/measures/filters.py b/measures/filters.py index 02f83d8fc..8ae5327cd 100644 --- a/measures/filters.py +++ b/measures/filters.py @@ -26,6 +26,7 @@ from measures.models import MeasureCondition from measures.models import MeasureType from measures.models.bulk_processing import MeasuresBulkCreator +from measures.models.bulk_processing import MeasuresBulkEditor from quotas.models import QuotaOrderNumber from regulations.models import Regulation from workbaskets.models import WorkBasket @@ -302,3 +303,13 @@ class MeasureCreateTaskFilter(TamatoFilter): class Meta: model = MeasuresBulkCreator fields = ["processing_state"] + +class MeasureEditTaskFilter(TamatoFilter): + """FilterSet for Bulk Measure Edit tasks.""" + + search_fields = "processing_state" + clear_url = reverse_lazy("measure-edit-process-queue") + + class Meta: + model = MeasuresBulkEditor + fields = ["processing_state"] diff --git a/measures/views/bulk_processing.py b/measures/views/bulk_processing.py index cebc68a26..02c77aac8 100644 --- a/measures/views/bulk_processing.py +++ b/measures/views/bulk_processing.py @@ -14,6 +14,7 @@ from common.views import WithPaginationListView from measures import models from measures.filters import MeasureCreateTaskFilter +from measures.filters import MeasureEditTaskFilter from measures.forms import CancelBulkProcessorTaskForm from measures.models.bulk_processing import MeasuresBulkCreator from measures.models.bulk_processing import ProcessingState @@ -213,7 +214,7 @@ class MeasuresEditProcessQueue( queryset = models.MeasuresBulkEditor.objects.filter( workbasket__status=WorkflowStatus.EDITING, ).order_by("-created_at") - filterset_class = MeasureCreateTaskFilter + filterset_class = MeasureEditTaskFilter def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) From 89855df542c0227ba54e67536ec4d9bc6df0b131 Mon Sep 17 00:00:00 2001 From: marya Date: Fri, 11 Oct 2024 17:03:04 +0100 Subject: [PATCH 07/26] ran linter --- measures/filters.py | 1 + 1 file changed, 1 insertion(+) diff --git a/measures/filters.py b/measures/filters.py index 8ae5327cd..73348d4f8 100644 --- a/measures/filters.py +++ b/measures/filters.py @@ -304,6 +304,7 @@ class Meta: model = MeasuresBulkCreator fields = ["processing_state"] + class MeasureEditTaskFilter(TamatoFilter): """FilterSet for Bulk Measure Edit tasks.""" From 47861c0c179c2ba253b0eea029f84f65db3c6491 Mon Sep 17 00:00:00 2001 From: Lauren Qurashi Date: Wed, 16 Oct 2024 11:25:57 +0100 Subject: [PATCH 08/26] Pull combined measure create and edit process code into a base class --- measures/views/bulk_processing.py | 134 +++++------------------------- 1 file changed, 19 insertions(+), 115 deletions(-) diff --git a/measures/views/bulk_processing.py b/measures/views/bulk_processing.py index 02c77aac8..f477f5777 100644 --- a/measures/views/bulk_processing.py +++ b/measures/views/bulk_processing.py @@ -78,28 +78,21 @@ def test_func(self) -> bool: return self.request.user.is_superuser -class MeasuresCreateProcessQueue( +class MeasuresProcessQueue( PermissionRequiredMixin, WithPaginationListView, ): - """UI endpoint for bulk creating Measures process queue.""" + """Base class for UI endpoint for bulk creating and editing Measures process queue.""" permission_required = [ "common.add_trackedmodel", "common.change_trackedmodel", ] - template_name = "measures/create-process-queue.jinja" - model = models.MeasuresBulkCreator - queryset = models.MeasuresBulkCreator.objects.filter( - workbasket__status=WorkflowStatus.EDITING, - ).order_by("-created_at") - filterset_class = MeasureCreateTaskFilter def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context["selected_link"] = "all" - context["selected_tab"] = "measure-process-queue" processing_state = self.request.GET.get("processing_state") if processing_state == "PROCESSING": @@ -199,16 +192,25 @@ def status_tag_generator(self, task: models.MeasuresBulkCreator) -> dict: } -class MeasuresEditProcessQueue( - PermissionRequiredMixin, - WithPaginationListView, -): +class MeasuresCreateProcessQueue(MeasuresProcessQueue): + """UI endpoint for bulk creating Measures process queue.""" + + template_name = "measures/create-process-queue.jinja" + model = models.MeasuresBulkCreator + queryset = models.MeasuresBulkCreator.objects.filter( + workbasket__status=WorkflowStatus.EDITING, + ).order_by("-created_at") + filterset_class = MeasureCreateTaskFilter + + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + context["selected_tab"] = "measure-process-queue" + return context + + +class MeasuresEditProcessQueue(MeasuresProcessQueue): """UI endpoint for bulk editing Measures process queue.""" - permission_required = [ - "common.add_trackedmodel", - "common.change_trackedmodel", - ] template_name = "measures/edit-process-queue.jinja" model = models.MeasuresBulkEditor queryset = models.MeasuresBulkEditor.objects.filter( @@ -218,103 +220,5 @@ class MeasuresEditProcessQueue( def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) - - context["selected_link"] = "all" context["selected_tab"] = "measure-edit-process-queue" - processing_state = self.request.GET.get("processing_state") - - if processing_state == "PROCESSING": - context["selected_link"] = "processing" - elif processing_state == ProcessingState.CANCELLED: - context["selected_link"] = "terminated" - elif processing_state == ProcessingState.FAILED_PROCESSING: - context["selected_link"] = "failed" - elif processing_state == ProcessingState.SUCCESSFULLY_PROCESSED: - context["selected_link"] = "completed" - # Provide template access to some UI / view utility functions. - context["status_tag_generator"] = self.status_tag_generator - context["can_terminate_task"] = self.can_terminate_task - context["is_task_failed"] = self.is_task_failed - context["is_task_terminated"] = self.is_task_terminated - # Apply the TAP standard date format within the UI. - context["datetime_format"] = settings.DATETIME_FORMAT - if context["selected_link"] == "processing": - context["object_list"] = self.get_processing_queryset() return context - - def get_processing_queryset(self): - """Returns a combined queryset of tasks either AWAITING_PROCESSING or - CURRENTLY_PROCESSING.""" - - return self.queryset.filter( - Q(processing_state=ProcessingState.AWAITING_PROCESSING) - | Q(processing_state=ProcessingState.CURRENTLY_PROCESSING), - ) - - def is_task_failed(self, task: models.MeasuresBulkCreator) -> bool: - """ - Return True if the task is in a failed state. - - Return False otherwise. - """ - - return task.processing_state == ProcessingState.FAILED_PROCESSING - - def is_task_terminated(self, task: MeasuresBulkCreator) -> bool: - """ - Return True if the task is in a cancelled state. Cancelled tasks are - surfaced as 'terminated' in the UI. - - Return False otherwise. - """ - - return task.processing_state == ProcessingState.CANCELLED - - def can_terminate_task(self, task: MeasuresBulkCreator) -> bool: - """ - Return True if a task is in a queued state and the current user is - permitted to terminate a task. - - Return False otherwise. - """ - - if ( - self.request.user.is_superuser - and task.processing_state in ProcessingState.queued_states() - ): - return True - - return False - - def status_tag_generator(self, task: models.MeasuresBulkCreator) -> dict: - """Returns a dict with text and a CSS class for a UI-friendly label for - a bulk creation task.""" - - if task.processing_state in [ - ProcessingState.CURRENTLY_PROCESSING, - ProcessingState.AWAITING_PROCESSING, - ]: - return { - "text": "Processing", - "tag_class": "tamato-badge-light-blue", - } - elif task.processing_state == ProcessingState.SUCCESSFULLY_PROCESSED: - return { - "text": "Completed", - "tag_class": "tamato-badge-light-green", - } - elif task.processing_state == ProcessingState.FAILED_PROCESSING: - return { - "text": "Failed", - "tag_class": "tamato-badge-light-red", - } - elif task.processing_state == ProcessingState.CANCELLED: - return { - "text": "Terminated", - "tag_class": "tamato-badge-light-yellow", - } - else: - return { - "text": "", - "tag_class": "", - } From ac86d1e2f8753c6a4db9f5f4c85f414833f90880 Mon Sep 17 00:00:00 2001 From: Lauren Qurashi Date: Wed, 16 Oct 2024 15:38:51 +0100 Subject: [PATCH 09/26] Refactor confirm edit sync template to show a number of measures not their ids --- .../jinja2/measures/confirm-edit-multiple.jinja | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/measures/jinja2/measures/confirm-edit-multiple.jinja b/measures/jinja2/measures/confirm-edit-multiple.jinja index f6ca07980..be69ed121 100644 --- a/measures/jinja2/measures/confirm-edit-multiple.jinja +++ b/measures/jinja2/measures/confirm-edit-multiple.jinja @@ -3,15 +3,15 @@ {% set page_title = "Edit measure details" %} -{% macro panel_title(edited_measures) %} - {% if edited_measures|length > 1 %} - {{ edited_measures.0._meta.verbose_name_plural|title }} {% for m in edited_measures %}{% if not loop.last %}{{ m|string }}, {% else %}{{ m|string }} {% endif %}{% endfor %}have been edited +{% macro panel_title(edited_measures_count) %} + {% if edited_measures_count > 1 %} + {{ edited_measures_count }} measures have been edited {% else %} - {{ edited_measures.0._meta.verbose_name|title }} {{ edited_measures.0|string }} has been edited + {{ edited_measures_count }} measure has been edited {% endif %} {% endmacro %} -{% macro panel_subtitle(created_measures) %} +{% macro panel_subtitle() %} This change has been added to your workbasket {% endmacro %} @@ -26,8 +26,8 @@
{{ govukPanel({ - "titleText": panel_title(edited_measures), - "text": panel_subtitle(edited_measures), + "titleText": panel_title(edited_measures_count), + "text": panel_subtitle(), "classes": "govuk-!-margin-bottom-7" }) }}

Next steps

From 0ed5fbc62c223b3d522e8800c16e53ae9fa8c042 Mon Sep 17 00:00:00 2001 From: Lauren Qurashi Date: Wed, 16 Oct 2024 15:40:20 +0100 Subject: [PATCH 10/26] Swap render for redirect in Sync done and create sync and async success views --- measures/urls.py | 13 +++++++++---- measures/views/wizard.py | 27 ++++++++++++++++----------- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/measures/urls.py b/measures/urls.py index be63756af..b53dfd3a7 100644 --- a/measures/urls.py +++ b/measures/urls.py @@ -45,8 +45,13 @@ ), path( "edit/done-async//", - views.MeasuresWizardCreateConfirm.as_view(), - name="measure-ui-edit-confirm", + views.MeasuresWizardAsyncConfirm.as_view(), + name="measure-ui-edit-async-confirm", + ), + path( + "edit/done-sync//", + views.MeasuresWizardSyncConfirm.as_view(), + name="measure-ui-edit-sync-confirm", ), path( "delete-multiple-measures/", @@ -63,8 +68,8 @@ ), path( "create/done-async//", - views.MeasuresWizardCreateConfirm.as_view(), - name="measure-ui-create-confirm", + views.MeasuresWizardAsyncConfirm.as_view(), + name="measure-ui-create-async-confirm", ), path( f"{detail}/edit-footnotes/", diff --git a/measures/views/wizard.py b/measures/views/wizard.py index df0b50a26..91aa23ef9 100644 --- a/measures/views/wizard.py +++ b/measures/views/wizard.py @@ -5,10 +5,10 @@ from crispy_forms_gds.helper import FormHelper from django.conf import settings from django.contrib.auth.mixins import PermissionRequiredMixin +from django.http import HttpResponseRedirect from django.shortcuts import redirect from django.shortcuts import render from django.template.loader import render_to_string -from django.urls import reverse from django.utils.decorators import method_decorator from django.views.generic import TemplateView from formtools.wizard.views import NamedUrlSessionWizardView @@ -167,7 +167,7 @@ def async_done(self, form_list, **kwargs): measures_bulk_editor.schedule_task() return redirect( - "measure-ui-edit-confirm", + "measure-ui-edit-async-confirm", expected_measures_count=len(db_selected_measures), ) @@ -197,15 +197,11 @@ def sync_done(self, form_list, **kwargs): edited_measures = self.edit_measures(selected_measures, cleaned_data) self.session_store.clear() - - context = self.get_context_data( - form=None, - edited_measures=edited_measures, - **kwargs, + return redirect( + "measure-ui-edit-sync-confirm", + edited_measures_count=len(edited_measures), ) - return render(self.request, "measures/confirm-edit-multiple.jinja", context) - @method_decorator(require_current_workbasket, name="dispatch") class MeasureCreateWizard( @@ -391,7 +387,7 @@ def async_done(self, form_list, **kwargs): measures_bulk_creator.schedule_task() return redirect( - "measure-ui-create-confirm", + "measure-ui-create-async-confirm", expected_measures_count=measures_bulk_creator.expected_measures_count, ) @@ -619,10 +615,19 @@ def get_template_names(self): ) -class MeasuresWizardCreateConfirm(TemplateView): +class MeasuresWizardAsyncConfirm(TemplateView): template_name = "measures/confirm-create-multiple-async.jinja" def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context["expected_measures_count"] = self.kwargs.get("expected_measures_count") + return context + + +class MeasuresWizardSyncConfirm(TemplateView): + template_name = "measures/confirm-edit-multiple.jinja" + + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + context["edited_measures_count"] = self.kwargs.get("edited_measures_count") return context From 925bc9c8bab8e38ff4a8c66e273b62559d1e3503 Mon Sep 17 00:00:00 2001 From: Lauren Qurashi Date: Thu, 17 Oct 2024 11:55:40 +0100 Subject: [PATCH 11/26] Change processing queue url to include create --- measures/urls.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/measures/urls.py b/measures/urls.py index b53dfd3a7..971430103 100644 --- a/measures/urls.py +++ b/measures/urls.py @@ -77,7 +77,7 @@ name="measure-ui-edit-footnotes", ), path( - "process-queue/", + "create-process-queue/", views.MeasuresCreateProcessQueue.as_view(), name="measure-create-process-queue", ), From 95c8206b1fd715687821727b0cc96b23d4cfdf20 Mon Sep 17 00:00:00 2001 From: Lauren Qurashi Date: Thu, 17 Oct 2024 12:05:56 +0100 Subject: [PATCH 12/26] change create measures queue tab selected tab name, and page title --- common/jinja2/common/celery_queues.jinja | 4 ++-- measures/jinja2/measures/create-process-queue.jinja | 2 +- measures/views/bulk_processing.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/common/jinja2/common/celery_queues.jinja b/common/jinja2/common/celery_queues.jinja index 8958d29c7..219c443cb 100644 --- a/common/jinja2/common/celery_queues.jinja +++ b/common/jinja2/common/celery_queues.jinja @@ -6,9 +6,9 @@ {% set links = [ { - "text": "Measure process queue", + "text": "Create", "href": url('measure-create-process-queue'), - "selected": selected_tab == "measure-process-queue" + "selected": selected_tab == "measure-create-process-queue" }, { "text": "Measure edit process queue", diff --git a/measures/jinja2/measures/create-process-queue.jinja b/measures/jinja2/measures/create-process-queue.jinja index 2d383e8be..c5ad5609e 100644 --- a/measures/jinja2/measures/create-process-queue.jinja +++ b/measures/jinja2/measures/create-process-queue.jinja @@ -6,7 +6,7 @@ {% set list_include = "includes/measures/create-task-list.jinja"%} -{% set page_title = "Measures process queue" %} +{% set page_title = "Creation queue" %} {% block breadcrumb %} diff --git a/measures/views/bulk_processing.py b/measures/views/bulk_processing.py index f477f5777..83b27bbb4 100644 --- a/measures/views/bulk_processing.py +++ b/measures/views/bulk_processing.py @@ -204,7 +204,7 @@ class MeasuresCreateProcessQueue(MeasuresProcessQueue): def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) - context["selected_tab"] = "measure-process-queue" + context["selected_tab"] = "measure-create-process-queue" return context From 005d2379a9b18995e0bd9d453e20ad433e5088d9 Mon Sep 17 00:00:00 2001 From: Lauren Qurashi Date: Thu, 17 Oct 2024 14:14:02 +0100 Subject: [PATCH 13/26] Update tab titles and heading semantics and add main heading --- common/jinja2/common/celery_queues.jinja | 3 ++- measures/jinja2/measures/create-process-queue.jinja | 2 +- measures/jinja2/measures/edit-process-queue.jinja | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/common/jinja2/common/celery_queues.jinja b/common/jinja2/common/celery_queues.jinja index 219c443cb..35eb46b25 100644 --- a/common/jinja2/common/celery_queues.jinja +++ b/common/jinja2/common/celery_queues.jinja @@ -11,7 +11,7 @@ "selected": selected_tab == "measure-create-process-queue" }, { - "text": "Measure edit process queue", + "text": "Edit", "href": url('measure-edit-process-queue'), "selected": selected_tab == "measure-edit-process-queue" }, @@ -32,6 +32,7 @@ {%- endset %} {% block content %} +

Measure processing queue

{{ fake_tabs(links) }}
{% block tab_content %}{% endblock %} diff --git a/measures/jinja2/measures/create-process-queue.jinja b/measures/jinja2/measures/create-process-queue.jinja index c5ad5609e..2547c486a 100644 --- a/measures/jinja2/measures/create-process-queue.jinja +++ b/measures/jinja2/measures/create-process-queue.jinja @@ -49,7 +49,7 @@
-

{{ page_title }}

+

{{ page_title }}