Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TP2000-1387 py312 async success page #1305

Merged
merged 30 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
3e42c2c
Add confirmation page to sync route
LaurenMullally Sep 27, 2024
00cb172
Redirect async route to create success page
LaurenMullally Sep 27, 2024
81b9959
Make measures a small m
LaurenMullally Oct 4, 2024
de53aee
WIP- Make edit process queue page
LaurenMullally Oct 4, 2024
f8e2bde
add expected measures count property to bulk editor
marya-shariq Oct 10, 2024
bc66887
Create and apply bulk edit measures processing state filter
marya-shariq Oct 11, 2024
89855df
ran linter
marya-shariq Oct 11, 2024
47861c0
Pull combined measure create and edit process code into a base class
LaurenMullally Oct 16, 2024
ac86d1e
Refactor confirm edit sync template to show a number of measures not …
LaurenMullally Oct 16, 2024
0ed5fbc
Swap render for redirect in Sync done and create sync and async succe…
LaurenMullally Oct 16, 2024
925bc9c
Change processing queue url to include create
LaurenMullally Oct 17, 2024
95c8206
change create measures queue tab selected tab name, and page title
LaurenMullally Oct 17, 2024
005d237
Update tab titles and heading semantics and add main heading
LaurenMullally Oct 17, 2024
efb9ea2
lint
LaurenMullally Oct 17, 2024
ce3216c
Merge branch 'master' into TP2000-1387-py312-async-success-page
LaurenMullally Oct 17, 2024
277c32e
forgot h2 closing tags oops
LaurenMullally Oct 17, 2024
7266bd6
Fix broken test due to changed url
LaurenMullally Oct 17, 2024
5037398
add "unknown number" to tasks with failed counts within template
LaurenMullally Oct 18, 2024
2704ed8
Update headings from content guidance
LaurenMullally Oct 24, 2024
f19c284
Add edit link to the home page
LaurenMullally Oct 24, 2024
04f9674
Remove secondary styling on button
LaurenMullally Oct 24, 2024
c16689d
Refresh button to redirect to edit tab
LaurenMullally Oct 24, 2024
6590dbb
remove create from the no bulk edit copy
LaurenMullally Oct 24, 2024
f4613ef
Add doc strings to the sync and async confirm views
LaurenMullally Oct 24, 2024
0fe71c9
Hook up create sync to success view
LaurenMullally Oct 24, 2024
90a41ba
Lint
LaurenMullally Oct 25, 2024
1f74961
Fix test to accommodate sync create redirect
LaurenMullally Oct 25, 2024
79fbecf
Merge branch 'master' into TP2000-1387-py312-async-success-page
LaurenMullally Oct 25, 2024
773c125
Merge branch 'master' into TP2000-1387-py312-async-success-page
LaurenMullally Nov 4, 2024
a9d5798
Merge branch 'master' into TP2000-1387-py312-async-success-page
LaurenMullally Nov 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions common/jinja2/common/celery_queues.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@

{% set links = [
{
"text": "Measure process queue",
"text": "Create measures queue",
"href": url('measure-create-process-queue'),
"selected": selected_tab == "measure-process-queue"
"selected": selected_tab == "measure-create-process-queue"
},
{
"text": "Edit measures queue",
"href": url('measure-edit-process-queue'),
"selected": selected_tab == "measure-edit-process-queue"
},
{
"text": "Rule check queue",
Expand All @@ -27,6 +32,7 @@
{%- endset %}

{% block content %}
<h1 class="govuk-heading-xl">Processing queues</h1>
{{ fake_tabs(links) }}
<div class="govuk-tabs__panel">
{% block tab_content %}{% endblock %}
Expand Down
10 changes: 9 additions & 1 deletion common/jinja2/common/homepage.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,20 @@
<p class="govuk-body">
<a href="{{ url('measure-create-process-queue') }}"
class="govuk-link"
>Measures process queue</a>
>Measures create process queue</a>
<br>
This queue shows the status of measures that you submitted for
creation.
</p>
<p class="govuk-body">
<a href="{{ url('measure-edit-process-queue') }}"
class="govuk-link"
>Measures edit process queue</a>
<br>
This queue shows the status of measures that you submitted for
editing.
</p>
<p class="govuk-body">
<a href="{{ url('workbaskets:rule-check-queue') }}"
class="govuk-link"
>Rule check queue</a>
Expand Down
2 changes: 1 addition & 1 deletion measures/editors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 12 additions & 0 deletions measures/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -302,3 +303,14 @@ 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"]
7 changes: 6 additions & 1 deletion measures/jinja2/includes/measures/create-task-list.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,13 @@
{%- endset %}

{% set item_count -%}
{%- if object.expected_measures_count == None -%}
{% set expected_measures_count = "unknown number" %}
{% else %}
{% set expected_measures_count = object.expected_measures_count %}
{%- endif%}
<span class="processed-count">
{{ object.successfully_processed_count }} of {{ object.expected_measures_count }} processed
{{ object.successfully_processed_count }} of {{ expected_measures_count }} processed
</span>
{%- endset %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down Expand Up @@ -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"
}) }}
</div>
</div>
</div>
Expand Down
41 changes: 41 additions & 0 deletions measures/jinja2/measures/confirm-edit-multiple.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{% extends "layouts/confirm.jinja" %}
{% from "components/breadcrumbs.jinja" import breadcrumbs %}

{% set page_title = "Edit measure details" %}

{% macro panel_title(edited_or_created_measures_count) %}
{% if edited_or_created_measures_count > 1 %}
{{ edited_or_created_measures_count }} measures have been edited or created
{% else %}
{{ edited_or_created_measures_count }} measure has been edited or created
{% endif %}
{% endmacro %}

{% macro panel_subtitle() %}
This change has been added to your workbasket
{% endmacro %}

{% block breadcrumb %}
{{ breadcrumbs(request, [
{"text": page_title },
])
}}
{% endblock %}

{% block content %}
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
{{ govukPanel({
"titleText": panel_title(edited_or_created_measures_count),
"text": panel_subtitle(),
"classes": "govuk-!-margin-bottom-7"
}) }}
<h2 class="govuk-heading-m">Next steps</h2>
<p class="govuk-body">To complete your task you must publish your change. </p>
{{ govukButton({
"text": "Go to workbasket summary",
"href": url("workbaskets:current-workbasket"),
}) }}
</div>
</div>
{% endblock %}
4 changes: 2 additions & 2 deletions measures/jinja2/measures/create-process-queue.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

{% set list_include = "includes/measures/create-task-list.jinja"%}

{% set page_title = "Measures process queue" %}
{% set page_title = "Create measures queue" %}


{% block breadcrumb %}
Expand Down Expand Up @@ -49,7 +49,7 @@
<div class="govuk-grid-row">

<div class="govuk-grid-column-full">
<h1 class="govuk-heading-xl">{{ page_title }}</h1>
<h2 class="govuk-heading-l">{{ page_title }}</h2>

<nav class="workbasket-filters">
<p class="govuk-body govuk-!-font-weight-bold">Filter results:</p>
Expand Down
86 changes: 86 additions & 0 deletions measures/jinja2/measures/edit-process-queue.jinja
Original file line number Diff line number Diff line change
@@ -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 = "Edit measures 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 %}
<div class="govuk-grid-row">

<div class="govuk-grid-column-full">
<h2 class="govuk-heading-l">{{ page_title }}</h2>

<nav class="workbasket-filters">
<p class="govuk-body govuk-!-font-weight-bold">Filter results:</p>
<div class="govuk-!-margin-top-2">
{{ inline_filter_links(filter_links_list) }}
</div>

{{ govukButton({
"html": refresh_button_content,
"href": url("measure-edit-process-queue"),
"classes": "govuk-button--primary align-right govuk-!-margin-bottom-0 refresh-button",
}) }}
</nav>
</div>

<div class="govuk-grid-column-full govuk-!-margin-bottom-3">
<hr class="govuk-section-break govuk-section-break--visible">
</div>

<div class="govuk-grid-column-full">
{% if object_list %}
{% include list_include%}
{% else %}
<p class="govuk-body">No bulk edit tasks with this status</p>
{% endif %}
</div>

<div class="govuk-grid-column-full">
{% include "includes/common/pagination.jinja" %}
</div>

</div>
{% endblock %}
4 changes: 4 additions & 0 deletions measures/models/bulk_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""

Expand Down
4 changes: 2 additions & 2 deletions measures/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,7 @@ def test_measure_form_wizard_finish(

complete_response = client_with_current_workbasket.get(response.url)

assert complete_response.status_code == 200
assert complete_response.status_code == 302


@unittest.mock.patch("workbaskets.models.WorkBasket.current")
Expand Down Expand Up @@ -2724,7 +2724,7 @@ def test_measures_wizard_create_confirm_view(valid_user_client):

expected_measures_count = 99
url = reverse(
"measure-ui-create-confirm",
"measure-ui-create-async-confirm",
kwargs={
"expected_measures_count": expected_measures_count,
},
Expand Down
26 changes: 23 additions & 3 deletions measures/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@
),
name="measure-ui-edit-multiple",
),
path(
"edit/done-async/<int:expected_measures_count>/",
LaurenMullally marked this conversation as resolved.
Show resolved Hide resolved
views.MeasuresWizardAsyncConfirm.as_view(),
name="measure-ui-edit-async-confirm",
),
path(
"edit/done-sync/<int:edited_or_created_measures_count>/",
views.MeasuresWizardSyncConfirm.as_view(),
name="measure-ui-edit-sync-confirm",
),
path(
"delete-multiple-measures/",
views.MeasureMultipleDelete.as_view(),
Expand All @@ -58,19 +68,29 @@
),
path(
"create/done-async/<int:expected_measures_count>/",
views.MeasuresWizardCreateConfirm.as_view(),
name="measure-ui-create-confirm",
views.MeasuresWizardAsyncConfirm.as_view(),
name="measure-ui-create-async-confirm",
),
path(
"create/done-sync/<int:edited_or_created_measures_count>/",
views.MeasuresWizardSyncConfirm.as_view(),
name="measure-ui-create-sync-confirm",
),
path(
f"{detail}/edit-footnotes/",
views.MeasureFootnotesUpdate.as_view(),
name="measure-ui-edit-footnotes",
),
path(
"process-queue/",
"create-process-queue/",
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/<int:pk>/",
views.CancelBulkProcessorTask.as_view(),
Expand Down
Loading
Loading