-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Cameron Lamb <[email protected]>
- Loading branch information
1 parent
d909282
commit b91c297
Showing
9 changed files
with
236 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,22 @@ DJANGO_FEEDBACK_GOVUK = { | |
"SERVICE_NAME": "<your-service>", | ||
"FEEDBACK_NOTIFICATION_EMAIL_TEMPLATE_ID": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", | ||
"FEEDBACK_NOTIFICATION_EMAIL_RECIPIENTS": ["[email protected]"], | ||
"COPY": { | ||
#...add any copy tags to override here | ||
} | ||
} | ||
|
||
The copy dict contains string IDs for all user-facing copy, defaulting to the following (override | ||
just the fields you want to, using the `{{ service_name }}` variable if necessary for _title and _body strings): | ||
|
||
```py | ||
{ | ||
"SUBMIT_TITLE": "Give feedback on {{ service_name }}", | ||
"CONFIRM_TITLE": "Feedback submitted", | ||
"CONFIRM_BODY": "Thank you for submitting your feedback.", | ||
"FIELD_SATISFACTION_LEGEND": "Overall, how did you feel about the service you received today?", | ||
"FIELD_COMMENT_LEGEND": "How could we improve this service?", | ||
"FIELD_COMMENT_HINT": "Do not include any personal or financial information, for example your National Insurance or credit card numbers.", | ||
} | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
from typing import List | ||
|
||
from django.conf import settings | ||
|
||
|
||
DEFAULTS = { | ||
"SERVICE_NAME": "Example service", | ||
"FEEDBACK_NOTIFICATION_EMAIL_TEMPLATE_ID": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", | ||
"FEEDBACK_NOTIFICATION_EMAIL_RECIPIENTS": [ | ||
"[email protected]", | ||
], | ||
"COPY": { | ||
"SUBMIT_TITLE": "Give feedback on {{ service_name }}", | ||
"CONFIRM_TITLE": "Feedback submitted", | ||
"CONFIRM_BODY": "Thank you for submitting your feedback.", | ||
"FIELD_SATISFACTION_LEGEND": "Overall, how did you feel about the service you received today?", | ||
"FIELD_COMMENT_LEGEND": "How could we improve this service?", | ||
"FIELD_COMMENT_HINT": "Do not include any personal or financial information, for example your National Insurance or credit card numbers.", | ||
}, | ||
} | ||
|
||
|
||
class DjangoFeedbackGovUKSettings: | ||
SERVICE_NAME: str | ||
FEEDBACK_NOTIFICATION_EMAIL_TEMPLATE_ID: str | ||
FEEDBACK_NOTIFICATION_EMAIL_RECIPIENTS: List[str] | ||
COPY_SUBMIT_TITLE: str | ||
COPY_CONFIRM_TITLE: str | ||
COPY_CONFIRM_BODY: str | ||
COPY_FIELD_SATISFACTION_LEGEND: str | ||
COPY_FIELD_COMMENT_LEGEND: str | ||
COPY_FIELD_COMMENT_HINT: str | ||
|
||
def __getattr__(self, attr): | ||
django_settings = getattr(settings, "DJANGO_FEEDBACK_GOVUK", {}) | ||
|
||
# Get COPY values | ||
if attr.startswith("COPY_"): | ||
copy_key = attr[5:] | ||
value = django_settings.get("COPY", {}).get(copy_key) | ||
if value: | ||
# Return the value from user settings | ||
return value | ||
# Return the value from defaults | ||
return DEFAULTS["COPY"][copy_key] | ||
|
||
if attr in django_settings: | ||
# Return the value from user settings | ||
return django_settings[attr] | ||
|
||
default_value = DEFAULTS.get(attr, None) | ||
if default_value is None and attr not in DEFAULTS: | ||
raise AttributeError(f"No value set for DJANGO_FEEDBACK_GOVUK['{attr}']") | ||
# Return the value from defaults | ||
return default_value | ||
|
||
|
||
dfg_settings = DjangoFeedbackGovUKSettings() |
8 changes: 4 additions & 4 deletions
8
django_feedback_govuk/templates/django_feedback_govuk/partials/confirm.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
|
||
<div class="govuk-panel govuk-panel--confirmation"> | ||
<h1 class="govuk-panel__title">Feedback submitted</h1> | ||
<div class="govuk-panel__body">Thank you for submitting your feedback.</div> | ||
</div> | ||
<div class="govuk-panel govuk-panel--confirmation"> | ||
<h1 class="govuk-panel__title">{{ confirm_title }}</h1> | ||
<div class="govuk-panel__body">{{ confirm_body }}</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -154,7 +154,10 @@ | |
|
||
# Django Feedback GovUK | ||
DJANGO_FEEDBACK_GOVUK = { | ||
"SERVICE_NAME": "Example Service", | ||
"SERVICE_NAME": "Example Project", | ||
"FEEDBACK_NOTIFICATION_EMAIL_TEMPLATE_ID": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", | ||
"FEEDBACK_NOTIFICATION_EMAIL_RECIPIENTS": ["[email protected]"], | ||
"COPY": { | ||
"submit_title": "Tell us what you thought about {{ service_name }}" | ||
} | ||
} |
Oops, something went wrong.