Skip to content

Commit

Permalink
Revert "feature/DT-1780-feedback-form" (#2970)
Browse files Browse the repository at this point in the history
  • Loading branch information
chopkinsmade authored Jan 25, 2024
1 parent 131d028 commit b77de68
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 199 deletions.
46 changes: 7 additions & 39 deletions dataworkspace/dataworkspace/apps/core/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@ class ConditionalSupportTypeRadioWidget(GOVUKDesignSystemWidgetMixin, forms.widg
option_template_name = "core/partial/support_type_radio_option.html"


class ConditionalSupportTypeCheckboxWidget(
GOVUKDesignSystemCheckboxesWidget, forms.widgets.CheckboxSelectMultiple
):
template_name = "design_system/checkbox.html"
option_template_name = "core/partial/support_type_checkbox_option.html"


class SupportForm(GOVUKDesignSystemForm):
class SupportTypes(models.TextChoices):
TECH_SUPPORT = "tech", "I would like to have technical support"
Expand Down Expand Up @@ -72,53 +65,28 @@ def clean(self):


class UserSatisfactionSurveyForm(GOVUKDesignSystemForm):
trying_to_do = GOVUKDesignSystemMultipleChoiceField(
required=True,
label="1. What were you trying to do today?",
help_text="Select all options that are relevant to you.",
widget=ConditionalSupportTypeCheckboxWidget(heading="h2", label_size="m", small=True),
choices=[(t.value, t.label) for t in TryingToDoType],
error_messages={
"required": "Select one or more options that explain what you were trying to do today."
},
)

trying_to_do_other_message = GOVUKDesignSystemCharField(
required=False,
label="Tell us what you were doing",
widget=GOVUKDesignSystemTextWidget(label_is_heading=False, label_size="m"),
)

how_satisfied = GOVUKDesignSystemRadioField(
required=True,
label="2. How do you feel about your experience of using Data Workspace today?",
label="1. Overall how satisfied are you with the current Data Workspace?",
widget=GOVUKDesignSystemRadiosWidget(heading="h2", label_size="m", small=True),
choices=[(t.value, t.label) for t in HowSatisfiedType],
error_messages={
"required": "Select an option for how Data workspace made you feel today."
},
)

describe_experience = GOVUKDesignSystemTextareaField(
trying_to_do = GOVUKDesignSystemMultipleChoiceField(
required=False,
label="3. Describe your experience (optional)",
widget=GOVUKDesignSystemTextareaWidget(heading="h2", label_size="m"),
label="2. What were you trying to do today? (optional)",
help_text="Select all options that are relevant to you.",
widget=GOVUKDesignSystemCheckboxesWidget(heading="h2", label_size="m", small=True),
choices=[(t.value, t.label) for t in TryingToDoType],
)

improve_service = GOVUKDesignSystemTextareaField(
required=False,
label="4. How could we improve the service? (optional)",
label="3. How could we improve the service? (optional)",
help_html=render_to_string("core/partial/user-survey-improve-service-hint.html"),
widget=GOVUKDesignSystemTextareaWidget(heading="h2", label_size="m"),
)

def clean_trying_to_do_other_message(self):
trying_to_do = self.cleaned_data.get("trying_to_do")
trying_to_do_other_message = self.cleaned_data.get("trying_to_do_other_message")
if not trying_to_do_other_message and trying_to_do and "other" in trying_to_do:
raise forms.ValidationError("'Tell us what you were doing' cannot be blank")
return trying_to_do_other_message


class NewsletterSubscriptionForm(forms.Form):
submit_action = forms.CharField()
Expand Down

This file was deleted.

8 changes: 3 additions & 5 deletions dataworkspace/dataworkspace/apps/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,21 +153,19 @@ class TryingToDoType(models.TextChoices):
looking = "looking", "Looking for data"
access_data = "access-data", "Trying to access data"
analyse_data = "analyse-data", "Analyse data"
share_date = "share-date", "Share data"
use_tool = "use-tool", "Use tools"
use_tool = "use-tool", "Use a tool"
create_visualisation = "create-visualisation", "Create a data visualisation"
share_date = "share-date", "Share data"
share_visualisation = "share-visualisation", "Share a data visualisation"
view_visualisation = "view-visualisation", "View a data visualisation"
support_guidance = "support-guidance", "Looking for support or guidance"
other = "other", "Other"
dont_know = "dont-know", "Don’t know"


class UserSatisfactionSurvey(TimeStampedModel):
how_satisfied = models.CharField(max_length=32, choices=HowSatisfiedType.choices)
trying_to_do = models.TextField(null=True, blank=True, choices=TryingToDoType.choices)
trying_to_do_other_message = models.TextField(null=True, blank=True)
improve_service = models.TextField(null=True, blank=True)
describe_experience = models.TextField(null=True, blank=True)


class NewsletterSubscription(TimeStampedModel):
Expand Down
2 changes: 0 additions & 2 deletions dataworkspace/dataworkspace/apps/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,6 @@ def form_valid(self, form):
how_satisfied=cleaned["how_satisfied"],
trying_to_do=",".join(cleaned["trying_to_do"]),
improve_service=cleaned["improve_service"],
trying_to_do_other_message=cleaned["trying_to_do_other_message"],
describe_experience=cleaned["describe_experience"],
)

return HttpResponseRedirect(f'{reverse("feedback")}?success=1')
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<div class="govuk-radios__item">
<input class="govuk-radios__input"
name="{{ widget.name }}"
type="radio"
{% if widget.value != None %}value="{{ widget.value|stringformat:'s' }}"{% endif %}
{% if widget.value == 'other' %}data-aria-controls="conditional-message"{% endif %}
{% include "django/forms/widgets/attrs.html" %}>
<label class="govuk-label govuk-radios__label" for="{{ widget.attrs.id }}">{{ widget.label }}</label>
<input
class="govuk-radios__input"
name="{{ widget.name }}"
type="radio"
{% if widget.value != None %}value="{{ widget.value|stringformat:'s' }}"{% endif %}
{% if widget.value == 'other' %}data-aria-controls="conditional-message"{% endif %}
{% include "django/forms/widgets/attrs.html" %}
>
<label class="govuk-label govuk-radios__label" for="{{ widget.attrs.id }}">
{{ widget.label }}
</label>
</div>
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<div class="govuk-hint">
<p>
Do not include any personal information, like your name or email address. We
will delete any personal information you do include.
Do not include any personal information, like your name or email address.
We will delete any personal information you do include.
</p>
<p>
We are unable to respond to any feedback you leave here.
For a response, fill out the <a class="govuk-link govuk-link--no-visited-state" href="/support-and-feedback/">support form</a>.
</p>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,33 @@

{% load waffle_tags %}

{% block page_title %}
Leave feedback - {{ block.super }}
{% endblock page_title %}
{% block page_title %}Leave feedback - {{ block.super }}{% endblock page_title %}
{% block go_back %}
{% if 'success' not in request.GET %}<a href="{{ referer }}" class="govuk-back-link">Back</a>{% endif %}
{% if 'success' not in request.GET %}
<a href="{{ referer }}" class="govuk-back-link">Back</a>
{% endif %}
{% endblock %}
{% block content %}
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
{% include 'design_system/error_summary.html' with form=form %}
{% if 'success' in request.GET %}
<h1 class="govuk-heading-l">Thank you for your feedback!</h1>
<p class="govuk-body-m">We are working hard to constantly improving our sevice and your feedback is valuable to us.</p>
<a class="govuk-button" href="{% url 'root' %}">Return home</a>
{% else %}
<h1 class="govuk-heading-xl">Leave feedback</h1>
<p class="govuk-body-m">
Fill in this short form to tell us about your experience of using this website. This form has 4 questions. It should take you less than 3 minutes to complete.
</p>
<p class="govuk-body-m">
We are unable to respond to any feedback you leave here. For a response, fill out the <a class="govuk-link govuk-link--no-visited-state"
href="{% url 'support' %}">support form.</a>
</p>
<form method="post" enctype="multipart/form-data" novalidate>
{% csrf_token %}
<fieldset class="govuk-fieldset">
<div class="govuk-checkboxes" data-module="govuk-checkboxes">
{{ form.trying_to_do }}
<div class="govuk-checkboxes__conditional govuk-checkboxes__conditional--hidden"
id="conditional-message">{{ form.trying_to_do_other_message }}</div>
</div>
{{ form.how_satisfied }} {{ form.describe_experience }} {{ form.improve_service }}
</fieldset>
<button type="submit" class="govuk-button">Leave feedback</button>
</form>
{% endif %}
</div>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
{% if 'success' in request.GET %}
<h1 class="govuk-heading-l">Thank you for your feedback!</h1>
<p class="govuk-body-m">We are working hard to constantly improving our sevice and your feedback is valuable to us.</p>
<a class="govuk-button" href="{% url 'root' %}">Return home</a>
{% else %}
<h1 class="govuk-heading-xl">Leave feedback</h1>
<p class="govuk-body-m">Fill in this short form to tell us about your experience of using this website.</p>
<p class="govuk-body-m">This form has 3 questions. It should take you less than 3 minutes to complete.</p>
<form method="post" enctype="multipart/form-data">
{% csrf_token %}
<fieldset class="govuk-fieldset">
{{ form.how_satisfied }}
{{ form.trying_to_do }}
{{ form.improve_service }}
</fieldset>
<button type="submit" class="govuk-button">Leave feedback</button>
</form>
{% endif %}
</div>
</div>
{% endblock %}
59 changes: 1 addition & 58 deletions dataworkspace/dataworkspace/tests/core/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from django.test import override_settings, Client
from django.urls import reverse

from dataworkspace.apps.core.models import NewsletterSubscription, UserSatisfactionSurvey
from dataworkspace.apps.core.models import NewsletterSubscription
from dataworkspace.tests.common import (
BaseTestCase,
get_http_sso_data,
Expand Down Expand Up @@ -544,60 +544,3 @@ def test_get_help_redirects_to_feedback_page(self):
response = self._authenticated_post(reverse("contact-us"), {"contact_type": "feedback"})
assert response.status_code == 200
self.assertRedirects(response, reverse("feedback"))


@pytest.mark.django_db
class TestFeedbackViews(BaseTestCase):
def test_missing_trying_to_do_returns_expected_error_message(self):
response = self._authenticated_post(reverse("feedback"), {})
assert response.status_code == 200
self.assertContains(
response, "Select one or more options that explain what you were trying to do today."
)

def test_missing_how_satisfied_returns_expected_error_message(self):
response = self._authenticated_post(reverse("feedback"), {})
assert response.status_code == 200
self.assertContains(
response, "Select an option for how Data workspace made you feel today."
)

def test_trying_to_do_value_is_other_and_trying_to_do_other_message_missing_returns_expected_error_message(
self,
):
response = self._authenticated_post(
reverse("feedback"), {"trying_to_do": "other", "trying_to_do_other_message": ""}
)
assert response.status_code == 200
self.assertContains(response, "Tell us what you were doing")

def test_trying_to_do_value_is_other_and_trying_to_do_other_message_value_present_doesnt_return_error(
self,
):
response = self._authenticated_post(
reverse("feedback"), {"trying_to_do": "other", "trying_to_do_other_message": "Hello"}
)
assert response.status_code == 200
self.assertNotContains(response, "'Tell us what you were doing' cannot be blank")

def test_submitting_valid_form_adds_expected_entry_to_django(
self,
):
response = self._authenticated_post(
reverse("feedback"),
{
"how_satisfied": "very-satified",
"trying_to_do": "other",
"trying_to_do_other_message": "Hello",
"improve_service": "abc",
"describe_experience": "def",
},
)
assert response.status_code == 200

survey_entry = UserSatisfactionSurvey.objects.first()
assert survey_entry.how_satisfied == "very-satified"
assert survey_entry.trying_to_do == "other"
assert survey_entry.trying_to_do_other_message == "Hello"
assert survey_entry.improve_service == "abc"
assert survey_entry.describe_experience == "def"

0 comments on commit b77de68

Please sign in to comment.