From c0c8cc9b6a4268776ad3c753abaf6ccdb4230215 Mon Sep 17 00:00:00 2001 From: Tomos Williams Date: Thu, 13 Feb 2025 15:51:06 +0000 Subject: [PATCH 1/4] content change, county or state -> county --- .../core/registration/includes/address-details-uk.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exporter/templates/core/registration/includes/address-details-uk.html b/exporter/templates/core/registration/includes/address-details-uk.html index 31f7903946..95dcd36551 100644 --- a/exporter/templates/core/registration/includes/address-details-uk.html +++ b/exporter/templates/core/registration/includes/address-details-uk.html @@ -36,7 +36,7 @@
- County or state + County
{{ registration_data.site.address.region}} From fd45a06b989fd1fedecfdf7d3945f78e9bc16ee8 Mon Sep 17 00:00:00 2001 From: Gurdeep Atwal Date: Mon, 17 Feb 2025 15:58:45 +0000 Subject: [PATCH 2/4] change sort order default --- caseworker/queues/views/cases.py | 6 +++-- .../caseworker/queues/views/test_cases.py | 24 +++++++++---------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/caseworker/queues/views/cases.py b/caseworker/queues/views/cases.py index 48e5162a01..1a684a90cb 100644 --- a/caseworker/queues/views/cases.py +++ b/caseworker/queues/views/cases.py @@ -143,9 +143,11 @@ def get_params(self): if session_sort_by: params["sort_by"] = session_sort_by elif self.queue_pk == ALL_CASES_QUEUE_ID: - params["sort_by"] = "submitted_at" - else: + # newest to oldest params["sort_by"] = "-submitted_at" + else: + # oldest to newest + params["sort_by"] = "submitted_at" self.request.session["case_search_sort_by"] = params["sort_by"] diff --git a/unit_tests/caseworker/queues/views/test_cases.py b/unit_tests/caseworker/queues/views/test_cases.py index 518d657e6f..a4d81ab7a9 100644 --- a/unit_tests/caseworker/queues/views/test_cases.py +++ b/unit_tests/caseworker/queues/views/test_cases.py @@ -19,7 +19,7 @@ "queue_id": ["00000000-0000-0000-0000-000000000001"], "selected_tab": ["all_cases"], "hidden": ["true"], - "sort_by": ["submitted_at"], + "sort_by": ["-submitted_at"], } @@ -313,7 +313,7 @@ def test_cases_queue_page_assigned_queues(authorized_client, mock_cases_search_t "queue_id": [queue_pk], "selected_tab": ["all_cases"], "hidden": ["false"], - "sort_by": ["-submitted_at"], + "sort_by": ["submitted_at"], } @@ -620,7 +620,7 @@ def test_tabs_with_all_cases_default(authorized_client, mock_cases_search, mock_ "page": ["1"], "queue_id": ["00000000-0000-0000-0000-000000000001"], "selected_tab": [tab], - "sort_by": ["submitted_at"], + "sort_by": ["-submitted_at"], } in head_request_history @@ -655,7 +655,7 @@ def test_tabs_on_all_cases_queue(authorized_client, mock_cases_search, tab_name, "page": ["1"], "queue_id": ["00000000-0000-0000-0000-000000000001"], "selected_tab": [tab_name], - "sort_by": ["submitted_at"], + "sort_by": ["-submitted_at"], } @@ -684,7 +684,7 @@ def test_tabs_on_team_queue( "page": ["1"], "queue_id": [queue_pk], "selected_tab": [tab_name], - "sort_by": ["-submitted_at"], + "sort_by": ["submitted_at"], } head_request_history = [x.qs for x in mock_cases_search_head.request_history] assert { @@ -692,7 +692,7 @@ def test_tabs_on_team_queue( "page": ["1"], "queue_id": [queue_pk], "selected_tab": ["all_cases"], - "sort_by": ["-submitted_at"], + "sort_by": ["submitted_at"], } in head_request_history tabs_with_hidden_param = ("my_cases", "open_queries") @@ -702,7 +702,7 @@ def test_tabs_on_team_queue( "page": ["1"], "queue_id": [queue_pk], "selected_tab": [tab], - "sort_by": ["-submitted_at"], + "sort_by": ["submitted_at"], } in head_request_history @@ -717,7 +717,7 @@ def test_tabs_on_team_queue_with_hidden_param( "page": ["1"], "queue_id": [queue_pk], "selected_tab": ["all_cases"], - "sort_by": ["-submitted_at"], + "sort_by": ["submitted_at"], } head_request_history = [x.qs for x in mock_cases_search_head.request_history] tabs_with_hidden_param = ("all_cases", "my_cases", "open_queries") @@ -727,7 +727,7 @@ def test_tabs_on_team_queue_with_hidden_param( "page": ["1"], "queue_id": [queue_pk], "selected_tab": [tab], - "sort_by": ["-submitted_at"], + "sort_by": ["submitted_at"], } in head_request_history @@ -1156,8 +1156,8 @@ def test_product_search_is_visible_to_specific_users_only( def test_queue_view_sort_params_persist(authorized_client): response = authorized_client.get(reverse("core:index")) assert response.status_code == 200 - assert authorized_client.session["case_search_sort_by"] == "submitted_at" + assert authorized_client.session["case_search_sort_by"] == "-submitted_at" - authorized_client.get(reverse("core:index") + "?sort_by=-submitted_at") + authorized_client.get(reverse("core:index") + "?sort_by=submitted_at") assert response.status_code == 200 - assert authorized_client.session["case_search_sort_by"] == "-submitted_at" + assert authorized_client.session["case_search_sort_by"] == "submitted_at" From 4515bae72147d4f8e081785c3aeae33cab79d769 Mon Sep 17 00:00:00 2001 From: Gurdeep Atwal Date: Wed, 12 Feb 2025 14:01:48 +0000 Subject: [PATCH 3/4] remove name --- exporter/f680/constants.py | 4 ---- exporter/f680/forms.py | 17 ----------------- exporter/f680/payloads.py | 14 ++++---------- exporter/f680/views.py | 29 ++++++++--------------------- 4 files changed, 12 insertions(+), 52 deletions(-) diff --git a/exporter/f680/constants.py b/exporter/f680/constants.py index 452db76305..dd0771b0cf 100644 --- a/exporter/f680/constants.py +++ b/exporter/f680/constants.py @@ -1,6 +1,2 @@ -class ApplicationFormSteps: - APPLICATION_NAME = "APPLICATION_NAME" - - class ApprovalTypeSteps: APPROVAL_TYPE = "APPROVAL_TYPE" diff --git a/exporter/f680/forms.py b/exporter/f680/forms.py index d9e1118874..788d66bb44 100644 --- a/exporter/f680/forms.py +++ b/exporter/f680/forms.py @@ -1,23 +1,6 @@ -from django import forms - from core.common.forms import BaseForm -class ApplicationNameForm(BaseForm): - class Layout: - TITLE = "Name of the application" - TITLE_AS_LABEL_FOR = "name" - SUBMIT_BUTTON_TEXT = "Continue" - - name = forms.CharField( - label="", - help_text="Give the application a reference name so you can refer back to it when needed", - ) - - def get_layout_fields(self): - return ("name",) - - class ApplicationSubmissionForm(BaseForm): class Layout: TITLE = "" diff --git a/exporter/f680/payloads.py b/exporter/f680/payloads.py index b7e84b492f..9f0531dc8c 100644 --- a/exporter/f680/payloads.py +++ b/exporter/f680/payloads.py @@ -1,17 +1,11 @@ from deepmerge import always_merger -from core.wizard.payloads import MergingPayloadBuilder, get_cleaned_data, get_questions_data -from .constants import ApplicationFormSteps +from core.wizard.payloads import get_cleaned_data, get_questions_data -class F680CreatePayloadBuilder(MergingPayloadBuilder): - payload_dict = { - ApplicationFormSteps.APPLICATION_NAME: get_cleaned_data, - } - - def build(self, form_dict): - payload = super().build(form_dict) - return {"application": payload} +class F680CreatePayloadBase: + def build(self, application_data={}): + return {"application": application_data} class F680PatchPayloadBuilder: diff --git a/exporter/f680/views.py b/exporter/f680/views.py index 175ef5a9df..6af54a4dac 100644 --- a/exporter/f680/views.py +++ b/exporter/f680/views.py @@ -4,22 +4,14 @@ from django.contrib.auth.mixins import AccessMixin from django.shortcuts import redirect from django.urls import reverse -from django.views.generic import FormView +from django.views.generic import FormView, TemplateView from core.auth.views import LoginRequiredMixin from core.decorators import expect_status -from core.wizard.views import BaseSessionWizardView -from .constants import ( - ApplicationFormSteps, -) -from .forms import ( - ApplicationNameForm, - ApplicationSubmissionForm, -) -from .payloads import ( - F680CreatePayloadBuilder, -) +from .forms import ApplicationSubmissionForm +from .payloads import F680CreatePayloadBase + from .services import ( post_f680_application, get_f680_application, @@ -37,10 +29,7 @@ def dispatch(self, request, *args, **kwargs): return super().dispatch(request, *args, **kwargs) -class F680ApplicationCreateView(LoginRequiredMixin, F680FeatureRequiredMixin, BaseSessionWizardView): - form_list = [ - (ApplicationFormSteps.APPLICATION_NAME, ApplicationNameForm), - ] +class F680ApplicationCreateView(LoginRequiredMixin, F680FeatureRequiredMixin, TemplateView): @expect_status( HTTPStatus.CREATED, @@ -58,11 +47,9 @@ def get_success_url(self, application_id): }, ) - def get_payload(self, form_dict): - return F680CreatePayloadBuilder().build(form_dict) - - def done(self, form_list, form_dict, **kwargs): - data = self.get_payload(form_dict) + def dispatch(self, request, *args, **kwargs): + # Dispatch is overriden to create a dummpy application + data = F680CreatePayloadBase().build() response_data, _ = self.post_f680_application(data) return redirect(self.get_success_url(response_data["id"])) From 0bfd980a2f6aa87e4bbece37435aad17d5c8d5a9 Mon Sep 17 00:00:00 2001 From: Gurdeep Atwal Date: Wed, 12 Feb 2025 20:58:10 +0000 Subject: [PATCH 4/4] remove name view --- exporter/f680/payloads.py | 5 -- exporter/f680/views.py | 12 ++--- .../exporter/applications/views/test_f680s.py | 46 +++---------------- 3 files changed, 13 insertions(+), 50 deletions(-) diff --git a/exporter/f680/payloads.py b/exporter/f680/payloads.py index 9f0531dc8c..3234627913 100644 --- a/exporter/f680/payloads.py +++ b/exporter/f680/payloads.py @@ -3,11 +3,6 @@ from core.wizard.payloads import get_cleaned_data, get_questions_data -class F680CreatePayloadBase: - def build(self, application_data={}): - return {"application": application_data} - - class F680PatchPayloadBuilder: def build(self, section, application_data, form_dict): answer_payload = {} diff --git a/exporter/f680/views.py b/exporter/f680/views.py index 6af54a4dac..5e2c05701e 100644 --- a/exporter/f680/views.py +++ b/exporter/f680/views.py @@ -4,13 +4,12 @@ from django.contrib.auth.mixins import AccessMixin from django.shortcuts import redirect from django.urls import reverse -from django.views.generic import FormView, TemplateView +from django.views.generic import FormView, RedirectView from core.auth.views import LoginRequiredMixin from core.decorators import expect_status from .forms import ApplicationSubmissionForm -from .payloads import F680CreatePayloadBase from .services import ( post_f680_application, @@ -29,7 +28,7 @@ def dispatch(self, request, *args, **kwargs): return super().dispatch(request, *args, **kwargs) -class F680ApplicationCreateView(LoginRequiredMixin, F680FeatureRequiredMixin, TemplateView): +class F680ApplicationCreateView(LoginRequiredMixin, F680FeatureRequiredMixin, RedirectView): @expect_status( HTTPStatus.CREATED, @@ -47,9 +46,10 @@ def get_success_url(self, application_id): }, ) - def dispatch(self, request, *args, **kwargs): - # Dispatch is overriden to create a dummpy application - data = F680CreatePayloadBase().build() + def get(self, request, *args, **kwargs): + super().get(request, *args, **kwargs) + # Data required to create a base application + data = {"application": {}} response_data, _ = self.post_f680_application(data) return redirect(self.get_success_url(response_data["id"])) diff --git a/unit_tests/exporter/applications/views/test_f680s.py b/unit_tests/exporter/applications/views/test_f680s.py index 8bd6d6c305..b3119f1e92 100644 --- a/unit_tests/exporter/applications/views/test_f680s.py +++ b/unit_tests/exporter/applications/views/test_f680s.py @@ -6,10 +6,7 @@ from pytest_django.asserts import assertTemplateUsed from core import client -from exporter.f680.constants import ( - ApplicationFormSteps, -) -from exporter.f680.forms import ApplicationNameForm, ApplicationSubmissionForm +from exporter.f680.forms import ApplicationSubmissionForm @pytest.fixture(autouse=True) @@ -68,13 +65,14 @@ def test_get_create_f680_view_success( self, authorized_client, f680_apply_url, - mock_f680_application_get, + f680_summary_url_with_application, + mock_application_post, ): response = authorized_client.get(f680_apply_url) - - assert isinstance(response.context["form"], ApplicationNameForm) - soup = BeautifulSoup(response.content, "html.parser") - assert "Name of the application" in soup.find("h1").text + assert response.status_code == 302 + assert response.url == f680_summary_url_with_application + assert mock_application_post.called_once + assert mock_application_post.last_request.json() == {"application": {}} def test_get_create_f680_view_fail_with_feature_flag_off( self, @@ -90,36 +88,6 @@ def test_get_create_f680_view_fail_with_feature_flag_off( in response.context[0].get("description").args ) - def test_post_to_create_f680_name_step_success( - self, - authorized_client, - f680_apply_url, - post_to_step, - f680_summary_url_with_application, - ): - response = post_to_step( - ApplicationFormSteps.APPLICATION_NAME, - {"name": "F680 Test"}, - ) - - assert response.status_code == 302 - assert response.url == f680_summary_url_with_application - - def test_post_to_create_f680_name_step_invalid_data( - self, - authorized_client, - f680_apply_url, - post_to_step, - ): - response = post_to_step( - ApplicationFormSteps.APPLICATION_NAME, - {"name": ""}, - ) - - assert isinstance(response.context["form"], ApplicationNameForm) - assert response.context["form"].errors - assert response.context["form"].errors.get("name")[0] == "This field is required." - class TestF680ApplicationSummaryView: def test_get_f680_summary_view_success(