diff --git a/poetry.lock b/poetry.lock index 6cec04452..8c9276947 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.1 and should not be changed by hand. [[package]] name = "amqp" @@ -1084,19 +1084,23 @@ Django = ">=3.2" [[package]] name = "django-feedback-govuk" -version = "0.2.8" +version = "0.2.9" description = "A Django app to gather and send internal Government staff feedback" optional = false -python-versions = ">=3.9,<4.0" -files = [ - {file = "django_feedback_govuk-0.2.8-py3-none-any.whl", hash = "sha256:bf136d296c7f584b2463fa7fbad58fe6efaf7b9ac310d787add12fa8aeaf4959"}, - {file = "django_feedback_govuk-0.2.8.tar.gz", hash = "sha256:7eae1f3841bae0353860bfbcb4b86656e88a3adbcfbfa2460b8efbac1ca79269"}, -] +python-versions = "^3.9" +files = [] +develop = false [package.dependencies] -crispy-forms-gds = ">=0.2.4,<0.3.0" +crispy-forms-gds = "^0.2.4" Django = ">=3.2,<4.3" -django-crispy-forms = ">=1.9,<2.0" +django-crispy-forms = "^1.9" + +[package.source] +type = "git" +url = "https://github.com/uktrade/django-feedback-govuk.git" +reference = "fix-missing-request-attribute" +resolved_reference = "6e18dc33748cd7b6e0fb71e16222f24b86f1f580" [[package]] name = "django-filter" @@ -4193,4 +4197,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p [metadata] lock-version = "2.0" python-versions = "^3.12" -content-hash = "0b824b7a899078b50ff18c9e7ad37d6abb143f6825152d57486e878c37a0671a" +content-hash = "1c4bd69d0f7de22d25fa8457290d739b303e360bc1df2fd9c6f14d157a8f3d1f" diff --git a/pyproject.toml b/pyproject.toml index 149565826..ec82236bc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,7 +23,7 @@ crispy-forms-gds = "^0.2.6" django-audit-log-middleware = "^0.0.4" django-hawk-drf = "^1.1.0" django-chunk-upload-handlers = "^0.0.14" -django-feedback-govuk = "^0.2.5" +django-feedback-govuk = "^0.2.9" django_log_formatter_ecs = "^0.0.5" django-staff-sso-client = "^4.2" notifications-python-client = "^8.2" diff --git a/src/config/settings/base.py b/src/config/settings/base.py index 9348afd8c..faa224815 100644 --- a/src/config/settings/base.py +++ b/src/config/settings/base.py @@ -645,6 +645,14 @@ "form": "django_feedback_govuk.forms.FeedbackForm", "view": "django_feedback_govuk.views.FeedbackView", }, + "hr-v1": { + "model": "feedback.models.HRFeedback", + "form": "feedback.forms.HRFeedbackForm", + "view": "feedback.views.HRFeedbackFormView", + "copy": { + "SUBMIT_TITLE": None, + }, + }, "search-v1": { "model": "feedback.models.SearchFeedbackV1", "form": "feedback.forms.SearchFeedbackV1Form", diff --git a/src/content/templates/content/navigation_page.html b/src/content/templates/content/navigation_page.html index a3e9ffc00..30880e2c1 100644 --- a/src/content/templates/content/navigation_page.html +++ b/src/content/templates/content/navigation_page.html @@ -2,6 +2,7 @@ {% load wagtailcore_tags %} {% block content %} + {% include 'feedback.html' %}

{{ page.title }}

{% for block in page.primary_content %} diff --git a/src/feedback/forms.py b/src/feedback/forms.py index ca74998f3..8b30b7102 100644 --- a/src/feedback/forms.py +++ b/src/feedback/forms.py @@ -3,7 +3,7 @@ from django_feedback_govuk.forms import SUBMIT_BUTTON, BaseFeedbackForm from django_feedback_govuk.models import SatisfactionOptions -from feedback.models import SearchFeedbackV1, SearchFeedbackV2 +from feedback.models import HRFeedback, SearchFeedbackV1, SearchFeedbackV2 class SearchFeedbackV1Form(BaseFeedbackForm): @@ -46,6 +46,53 @@ def __init__(self, *args, **kwargs): self.helper.layout.append(SUBMIT_BUTTON) +class HRFeedbackForm(BaseFeedbackForm): + class Meta: + model = HRFeedback + fields = ["useful", "comment", "page_url", "contactable", "submitter"] + widgets = { + "useful": HiddenInput(), + "page_url": HiddenInput(), + } + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + + self.fields["useful"].label = "" + self.fields["comment"].label = "" + self.fields["contactable"].label = ( + "Do you wish to be contacted for further research opportunities?" + ) + self.fields["page_url"].label = "" + + self.helper.layout.remove(SUBMIT_BUTTON) + self.helper.layout.append( + Fieldset( + legend="Providing feedback on your experience will help us improve the service", + legend_size=Size.MEDIUM, + ) + ) + self.helper.layout.append(Field("page_url")) + self.helper.layout.append(Field("useful")) + self.helper.layout.append( + Fieldset( + Field("comment"), + Field("contactable"), + legend="Why was this page not useful?", + legend_size=Size.SMALL, + ) + ) + self.helper.layout.append(SUBMIT_BUTTON) + self.helper.layout.append( + Button( + "close", + "Close feedback form", + css_class="govuk-button--secondary", + formmethod="dialog", + ) + ) + + class SearchFeedbackV2Form(BaseFeedbackForm): class Meta: model = SearchFeedbackV2 diff --git a/src/feedback/migrations/0004_hrfeedback.py b/src/feedback/migrations/0004_hrfeedback.py new file mode 100644 index 000000000..9edceb486 --- /dev/null +++ b/src/feedback/migrations/0004_hrfeedback.py @@ -0,0 +1,36 @@ +# Generated by Django 4.2.11 on 2024-05-14 08:14 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ("django_feedback_govuk", "0004_alter_basefeedback_id"), + ("feedback", "0003_searchfeedbackv2"), + ] + + operations = [ + migrations.CreateModel( + name="HRFeedback", + fields=[ + ( + "basefeedback_ptr", + models.OneToOneField( + auto_created=True, + on_delete=django.db.models.deletion.CASCADE, + parent_link=True, + primary_key=True, + serialize=False, + to="django_feedback_govuk.basefeedback", + ), + ), + ("page_url", models.CharField(blank=True)), + ("useful", models.BooleanField(default=True)), + ("contactable", models.BooleanField(default=False)), + ("comment", models.TextField(blank=True)), + ], + bases=("django_feedback_govuk.basefeedback",), + ), + ] diff --git a/src/feedback/models.py b/src/feedback/models.py index 280677fea..47f6939b2 100644 --- a/src/feedback/models.py +++ b/src/feedback/models.py @@ -2,6 +2,13 @@ from django_feedback_govuk.models import BaseFeedback, SatisfactionOptions +class HRFeedback(BaseFeedback): + page_url = models.CharField(blank=True) + useful = models.BooleanField(default=True) + contactable = models.BooleanField(default=False) + comment = models.TextField(blank=True) + + class SearchFeedbackV1(BaseFeedback): satisfaction = models.CharField(max_length=30, choices=SatisfactionOptions.choices) comment = models.TextField(blank=True) diff --git a/src/feedback/templates/feedback.html b/src/feedback/templates/feedback.html new file mode 100644 index 000000000..1084acea9 --- /dev/null +++ b/src/feedback/templates/feedback.html @@ -0,0 +1,79 @@ +{% load feedback_tags %} + +
+
+
Is this page useful?
+ + +
+
+ + + {% feedback_submit form_id="hr-v1" %} + + diff --git a/src/feedback/views.py b/src/feedback/views.py index 00d00b58a..0a9242ca9 100644 --- a/src/feedback/views.py +++ b/src/feedback/views.py @@ -2,3 +2,6 @@ class SearchFeedbackV2FormView(FeedbackView): ... + + +class HRFeedbackFormView(FeedbackView): ...