Skip to content

Commit

Permalink
PC-505: Add new GBIS feedback questions
Browse files Browse the repository at this point in the history
  • Loading branch information
chidin194 committed Oct 23, 2023
1 parent 21a6bd0 commit d63cc3e
Show file tree
Hide file tree
Showing 9 changed files with 328 additions and 169 deletions.
69 changes: 58 additions & 11 deletions help_to_heat/frontdoor/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,34 +598,81 @@
"value": "No loft",
},
)
multichoice_options = (
multichoice_options_agreement = (
{
"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"),
},
)

multichoice_options_satisfaction = (
{
"value": "Not sure / not applicable",
"label": _("Not sure / not applicable"),
"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",
},
)

multichoice_options_service_usage = (
{
"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": "Other",
"label": _("Other"),
},
)



postcode_regex_collection = (
# allow both upper and lower cases, no or multiple spaces in between outward and inward code
r"^\s*[a-zA-Z]{1,2}\d[\da-zA-Z]?(\s*\d[a-zA-Z]{2})*\s*$"
Expand Down
27 changes: 21 additions & 6 deletions help_to_heat/frontdoor/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -725,24 +725,39 @@ 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.multichoice_options_agreement,
"multichoice_options_satisfaction": schemas.multichoice_options_satisfaction,
"multichoice_options_service_usage": schemas.multichoice_options_service_usage,
"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 is True:
return self.get(request, session_id, page_name, errors=errors)
else:
return redirect("frontdoor:feedback-thanks")
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 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 d63cc3e

Please sign in to comment.