Skip to content

Commit ac963f2

Browse files
committed
Create nicer notifications on DREF
1 parent a55abd9 commit ac963f2

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

dref/serializers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ def create(self, validated_data):
426426
return dref_assessment_report
427427
dref = super().create(validated_data)
428428
transaction.on_commit(
429-
lambda: send_dref_email.delay(dref.id)
429+
lambda: send_dref_email.delay(dref.id, 'New')
430430
)
431431
return dref
432432

@@ -460,7 +460,7 @@ def update(self, instance, validated_data):
460460
return dref_assessment_report
461461
dref = super().update(instance, validated_data)
462462
transaction.on_commit(
463-
lambda: send_dref_email.delay(dref.id)
463+
lambda: send_dref_email.delay(dref.id, 'Updated')
464464
)
465465
return dref
466466

dref/tasks.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66

77

88
@shared_task
9-
def send_dref_email(dref_id):
9+
def send_dref_email(dref_id, new_or_updated=''):
1010
instance = Dref.objects.get(id=dref_id)
1111
email_context = get_email_context(instance)
1212
users_emails = [t.email for t in instance.users.iterator()]
1313
if users_emails:
1414
send_notification(
15-
f'New DREF: {instance.title}',
15+
f'{new_or_updated} DREF: {instance.title}',
1616
users_emails,
1717
render_to_string('email/dref/dref.html', email_context),
18-
'New DREF'
18+
f'{new_or_updated} DREF'
1919
)
2020
return email_context

0 commit comments

Comments
 (0)