-
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.
DWPF-703 removes email sending logic, notify package and its dependen…
…cies (#24) removed logic inside form_valid() removed code inside notify.py removed notifications-python-client with poetry remove
- Loading branch information
1 parent
83d5069
commit 4ea28fb
Showing
17 changed files
with
126 additions
and
284 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 |
---|---|---|
|
@@ -33,14 +33,9 @@ You'll need an API key and template ID from the gov.uk Notify service. | |
CRISPY_ALLOWED_TEMPLATE_PACKS = ["gds"] | ||
CRISPY_TEMPLATE_PACK = "gds" | ||
|
||
# Gov Notify | ||
GOVUK_NOTIFY_API_KEY="<your-api-key>" | ||
|
||
# Django Feedback GovUK | ||
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 | ||
}, | ||
|
@@ -240,3 +235,19 @@ poetry config pypi-token.pypi XXXXXXXX | |
``` | ||
|
||
Now the make commands should work as expected. | ||
|
||
## Sending automated emails after form submission | ||
|
||
Based on the needs of your project you may want to be notified of the feedback received. For example you might want to receive an email if there is new feedback to be reviewed. To do this you can create a method and call it on a regular schedule (e.g. once a day) through cron, Celery Beat, etc. | ||
|
||
``` | ||
feedback_submitted_past_day = ( | ||
BaseFeedback.objects.all().filter( | ||
submitted_at__gte=timezone.now() + timedelta(days=-1), | ||
).exists() | ||
) | ||
if feedback_submitted_past_day: | ||
send_email() # This is not a real method, just an example to show this is where the send email logic would go. | ||
``` | ||
|
||
This can be achieved through the [GovUK Notify](https://docs.notifications.service.gov.uk/python.html#python-client-documentation) Client. |
15 changes: 9 additions & 6 deletions
15
django_feedback_govuk/migrations/0002_alter_feedback_submitter.py
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,21 +1,24 @@ | ||
# Generated by Django 3.2.18 on 2023-05-12 05:15 | ||
|
||
import django.db.models.deletion | ||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
('django_feedback_govuk', '0001_initial'), | ||
("django_feedback_govuk", "0001_initial"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='feedback', | ||
name='submitter', | ||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL), | ||
model_name="feedback", | ||
name="submitter", | ||
field=models.ForeignKey( | ||
null=True, | ||
on_delete=django.db.models.deletion.CASCADE, | ||
to=settings.AUTH_USER_MODEL, | ||
), | ||
), | ||
] |
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -7,10 +7,6 @@ | |
|
||
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", | ||
|
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
1 change: 0 additions & 1 deletion
1
django_feedback_govuk/templates/django_feedback_govuk/templates/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,3 +1,2 @@ | ||
|
||
{% load feedback_tags %} | ||
{% feedback_confirm form_id=form_id %} |
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
39 changes: 30 additions & 9 deletions
39
example_project/custom_feedback/migrations/0001_initial.py
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,26 +1,47 @@ | ||
# Generated by Django 4.1.10 on 2023-08-07 12:55 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
('django_feedback_govuk', '0004_alter_basefeedback_id'), | ||
("django_feedback_govuk", "0004_alter_basefeedback_id"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='CustomFeedback', | ||
name="CustomFeedback", | ||
fields=[ | ||
('basefeedback_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='django_feedback_govuk.basefeedback')), | ||
('satisfaction', models.CharField(choices=[('very_dissatisfied', 'Very dissatisfied'), ('dissatisfied', 'Dissatisfied'), ('neutral', 'Neither satisfied or dissatisfied'), ('satisfied', 'Satisfied'), ('very_satisfied', 'Very satisfied')], max_length=30)), | ||
('comment', models.TextField(blank=True)), | ||
('extra_comments', models.TextField(blank=True)), | ||
( | ||
"basefeedback_ptr", | ||
models.OneToOneField( | ||
auto_created=True, | ||
on_delete=django.db.models.deletion.CASCADE, | ||
parent_link=True, | ||
primary_key=True, | ||
serialize=False, | ||
to="django_feedback_govuk.basefeedback", | ||
), | ||
), | ||
( | ||
"satisfaction", | ||
models.CharField( | ||
choices=[ | ||
("very_dissatisfied", "Very dissatisfied"), | ||
("dissatisfied", "Dissatisfied"), | ||
("neutral", "Neither satisfied or dissatisfied"), | ||
("satisfied", "Satisfied"), | ||
("very_satisfied", "Very satisfied"), | ||
], | ||
max_length=30, | ||
), | ||
), | ||
("comment", models.TextField(blank=True)), | ||
("extra_comments", models.TextField(blank=True)), | ||
], | ||
bases=('django_feedback_govuk.basefeedback',), | ||
bases=("django_feedback_govuk.basefeedback",), | ||
), | ||
] |
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
Oops, something went wrong.