Skip to content

Commit

Permalink
Merge pull request #242 from UKGovernmentBEIS/staging
Browse files Browse the repository at this point in the history
Merge staging into main
  • Loading branch information
chidin194 authored Oct 25, 2023
2 parents 77bcc05 + c5acddc commit 6045a95
Show file tree
Hide file tree
Showing 9 changed files with 367 additions and 180 deletions.
68 changes: 57 additions & 11 deletions help_to_heat/frontdoor/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,30 +598,76 @@
"value": "No loft",
},
)
multichoice_options = (
agreement_multichoice_options = (
{
"value": "Completely disagree",
"label": _("Completely disagree"),
"value": "Completely agree",
"label": _("Completely agree"),
},
{
"value": "Disagree",
"label": _("Disagree"),
"value": "Agree",
"label": _("Agree"),
},
{
"value": "Neutral",
"label": _("Neutral"),
},
{
"value": "Agree",
"label": _("Agree"),
"value": "Disagree",
"label": _("Disagree"),
},
{
"value": "Completely agree",
"label": _("Completely agree"),
"value": "Completely disagree",
"label": _("Completely disagree"),
},
)

satisfaction_multichoice_options = (
{
"value": "Very satisfied",
"label": _("Very satisfied"),
},
{
"value": "Somewhat satisfied",
"label": _("Somewhat satisfied"),
},
{
"value": "Neither satisfied nor dissatisfied",
"label": _("Neither satisfied nor dissatisfied"),
},
{
"value": "Somewhat dissatisfied",
"label": _("Somewhat dissatisfied"),
},
{
"value": "Very dissatisfied",
"label": _("Very dissatisfied"),
},
)

service_usage_multichoice_options = (
{
"value": "To find ways to reduce my energy bills",
"label": _("To find ways to reduce my energy bills"),
},
{
"value": "To find ways to reduce my carbon emissions",
"label": _("To find ways to reduce my carbon emissions"),
},
{
"value": "To find ways to install a specific measure in my home",
"label": _("To find ways to install a specific measure in my home"),
},
{
"value": "To find ways to improve my EPC rating",
"label": _("To find ways to improve my EPC rating"),
},
{
"value": "To find ways to make my home more comfortable",
"label": _("To find ways to make my home more comfortable"),
},
{
"value": "Not sure / not applicable",
"label": _("Not sure / not applicable"),
"value": "Other",
"label": _("Other"),
},
)

Expand Down
34 changes: 28 additions & 6 deletions help_to_heat/frontdoor/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -725,24 +725,46 @@ def get_context(self, session_id, *args, **kwargs):


class FeedbackView(utils.MethodDispatcher):
def get(self, request, session_id=None, page_name=None):
def get(self, request, session_id=None, page_name=None, errors=None):
template_name = "frontdoor/feedback.html"
prev_page_url = page_name and reverse("frontdoor:page", kwargs=dict(session_id=session_id, page_name=page_name))
context = {
"session_id": session_id,
"page_name": page_name,
"prev_url": prev_page_url,
"multichoice_options": schemas.multichoice_options,
"multichoice_options_agreement": schemas.agreement_multichoice_options,
"multichoice_options_satisfaction": schemas.satisfaction_multichoice_options,
"multichoice_options_service_usage": schemas.service_usage_multichoice_options,
"errors": errors,
}
return render(request, template_name=template_name, context=context)

def post(self, request, session_id=None, page_name=None):
data = request.POST.dict()
interface.api.feedback.save_feedback(session_id, page_name, data)
if session_id and page_name:
return redirect("frontdoor:feedback-thanks", session_id=session_id, page_name=page_name)
errors = self.validate(data)
if errors:
return self.get(request, session_id, page_name, errors=errors)
else:
interface.api.feedback.save_feedback(session_id, page_name, data)
if session_id and page_name:
return redirect("frontdoor:feedback-thanks", session_id=session_id, page_name=page_name)

else:
return redirect("frontdoor:feedback-thanks")

def validate(self, data):
if (
(not data.get("satisfaction"))
and (not data.get("usage-reason"))
and (not data.get("guidance"))
and (not data.get("accuracy"))
and (not data.get("advice"))
and (data.get("more-detail") == "")
):
errors = True
return errors
else:
return redirect("frontdoor:feedback-thanks")
return None


def feedback_thanks_view(request, session_id=None, page_name=None):
Expand Down
Binary file modified help_to_heat/locale/cy/LC_MESSAGES/django.mo
Binary file not shown.
Loading

0 comments on commit 6045a95

Please sign in to comment.