Skip to content

Commit

Permalink
Added initial feedback form
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesstottmoj committed Dec 2, 2024
1 parent ff1b95d commit 144e611
Show file tree
Hide file tree
Showing 9 changed files with 196 additions and 0 deletions.
41 changes: 41 additions & 0 deletions controlpanel/api/migrations/0048_feedback.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Generated by Django 5.1.2 on 2024-11-29 15:32

# Third-party
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("api", "0047_app_cloud_platform_role_arn"),
]

operations = [
migrations.CreateModel(
name="Feedback",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
(
"satisfaction_rating",
models.IntegerField(
choices=[
(5, "Very satisfied"),
(4, "Satisfied"),
(3, "Neither satisfied or dissatisfied"),
(2, "Dissatisfied"),
(1, "Very dissatisfied"),
]
),
),
("suggestions", models.TextField()),
],
options={
"db_table": "control_panel_api_feedback",
},
),
]
1 change: 1 addition & 0 deletions controlpanel/api/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from controlpanel.api.models.app import App
from controlpanel.api.models.app_ip_allowlist import AppIPAllowList
from controlpanel.api.models.apps3bucket import AppS3Bucket
from controlpanel.api.models.feedback import Feedback
from controlpanel.api.models.iam_managed_policy import IAMManagedPolicy
from controlpanel.api.models.parameter import Parameter
from controlpanel.api.models.policys3bucket import PolicyS3Bucket
Expand Down
23 changes: 23 additions & 0 deletions controlpanel/api/models/feedback.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Third-party
from django.db import models


class Feedback(models.Model):
SATISFACTION_RATINGS = [
(5, "Very satisfied"),
(4, "Satisfied"),
(3, "Neither satisfied or dissatisfied"),
(2, "Dissatisfied"),
(1, "Very dissatisfied"),
]

satisfaction_rating = models.IntegerField(
choices=SATISFACTION_RATINGS,
null=False,
blank=False,
)

suggestions = models.TextField()

class Meta:
db_table = "control_panel_api_feedback"
10 changes: 10 additions & 0 deletions controlpanel/frontend/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from controlpanel.api.models import (
QUICKSIGHT_EMBED_PERMISSION,
App,
Feedback,
S3Bucket,
Tool,
User,
Expand Down Expand Up @@ -655,3 +656,12 @@ def grant_access(self):
self.user.user_permissions.add(permission)
else:
self.user.user_permissions.remove(permission)


class FeedbackForm(forms.ModelForm):
class Meta:
model = Feedback
fields = [
"satisfaction_rating",
"suggestions",
]
80 changes: 80 additions & 0 deletions controlpanel/frontend/jinja2/feedback-create.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{% from "error-message/macro.html" import govukErrorMessage %}
{% from "label/macro.html" import govukLabel %}
{% from "radios/macro.html" import govukRadios %}
{% from "includes/auth0-connections-form.html" import auth0_connections_form with context %}


{% extends "base.html" %}

{% set page_title = "Feedback" %}

{% block content %}
<h1 class="govuk-heading-xl">Give feedback on the Analytical Platform</h1>


<form method="post" id="feedback" action="{{ url("feedback-create") }}">
{{ csrf_input }}

{{ govukRadios({
"name": "satisfaction_rating",
"fieldset": {
"legend": {
"text": "Satisfaction survey",
"classes": "govuk-fieldset__legend--l",
},
},
"items": [
{
"value": 5,
"text": "Very satisfied",
"checked": form.satisfaction_rating.value() == "5"
},
{
"value": 4,
"text": "Satisfied",
"checked": form.satisfaction_rating.value() == "4"
},
{
"value": 3,
"text": "Neither satisfied or dissatisfied",
"checked": form.satisfaction_rating.value() == "3"
},
{
"value": 2,
"text": "Dissatisfied",
"checked": form.satisfaction_rating.value() == "2"
},
{
"value": 1,
"text": "Very dissatisfied",
"checked": form.satisfaction_rating.value() == "1"
},
],
"errorMessage": { "text": form.errors.get("satisfaction_rating") } if form.errors.get("satisfaction_rating") else {}
}) }}



<div class="govuk-form-group {%- if form.errors.get("suggestions") %} govuk-form-group--error{% endif %}">
<h2 class="govuk-label-wrapper">
<label class="govuk-label govuk-label--l" for="{{form.suggestions.id_for_label}}">
How can we improve this service?
</label>
</h2>
<div id="more-detail-hint" class="govuk-hint">
Do not include personal or financial information, like your National Insurance number or credit card details.
</div>

{% if form.errors.get("suggestions") %}
{{ govukErrorMessage({"text": form.errors.get("suggestions")}) }}
{% endif %}

<textarea class="govuk-textarea" id="{{form.suggestions.id_for_label}}" name="{{form.suggestions.html_name}}" rows="5" aria-describedby="more-detail-hint"></textarea>
</div>


<div class="govuk-form-group">
<button class="govuk-button">Send feedback</button>
</div>
</form>
{% endblock %}
12 changes: 12 additions & 0 deletions controlpanel/frontend/jinja2/feedback-thanks.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{% from "error-message/macro.html" import govukErrorMessage %}
{% from "includes/auth0-connections-form.html" import auth0_connections_form with context %}


{% extends "base.html" %}

{% set page_title = "Thank you" %}

{% block content %}
<h1 class="govuk-heading-xl">Thank you for your feedback</h1>
<p class="govuk-body">Your feedback will help us improve the service.</p>
{% endblock %}
2 changes: 2 additions & 0 deletions controlpanel/frontend/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,4 +268,6 @@
),
path("parameters/<int:pk>/delete/", views.ParameterDelete.as_view(), name="delete-parameter"),
path("quicksight/", views.QuicksightView.as_view(), name="quicksight"),
path("feedback/", views.CreateFeedback.as_view(), name="feedback-create"),
path("feedback/thanks", views.FeedbackThanks.as_view(), name="feedback-thanks"),
]
1 change: 1 addition & 0 deletions controlpanel/frontend/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
UpdateIAMManagedPolicyAccessLevel,
WebappBucketList,
)
from controlpanel.frontend.views.feedback import CreateFeedback, FeedbackThanks
from controlpanel.frontend.views.help import Help
from controlpanel.frontend.views.ip_allowlist import (
IPAllowlistCreate,
Expand Down
26 changes: 26 additions & 0 deletions controlpanel/frontend/views/feedback.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Third-party
from django.urls import reverse_lazy
from django.views.generic import TemplateView
from django.views.generic.edit import CreateView, FormMixin

# First-party/Local
from controlpanel.api.models import Feedback
from controlpanel.frontend.forms import FeedbackForm
from controlpanel.oidc import OIDCLoginRequiredMixin


class CreateFeedback(OIDCLoginRequiredMixin, CreateView):
form_class = FeedbackForm
model = Feedback
template_name = "feedback-create.html"

def get_success_url(self):
return reverse_lazy("feedback-thanks")

def form_valid(self, form):
form.save()
return FormMixin.form_valid(self, form)


class FeedbackThanks(OIDCLoginRequiredMixin, TemplateView):
template_name = "feedback-thanks.html"

0 comments on commit 144e611

Please sign in to comment.