Skip to content

Commit

Permalink
Merge pull request #1545 from IFRCGo/fix/make-nicer-notifications-on-…
Browse files Browse the repository at this point in the history
…dref

Create nicer notifications on DREF
  • Loading branch information
szabozoltan69 authored Oct 3, 2022
2 parents a55abd9 + ac963f2 commit 2d35f82
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions dref/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ def create(self, validated_data):
return dref_assessment_report
dref = super().create(validated_data)
transaction.on_commit(
lambda: send_dref_email.delay(dref.id)
lambda: send_dref_email.delay(dref.id, 'New')
)
return dref

Expand Down Expand Up @@ -460,7 +460,7 @@ def update(self, instance, validated_data):
return dref_assessment_report
dref = super().update(instance, validated_data)
transaction.on_commit(
lambda: send_dref_email.delay(dref.id)
lambda: send_dref_email.delay(dref.id, 'Updated')
)
return dref

Expand Down
6 changes: 3 additions & 3 deletions dref/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@


@shared_task
def send_dref_email(dref_id):
def send_dref_email(dref_id, new_or_updated=''):
instance = Dref.objects.get(id=dref_id)
email_context = get_email_context(instance)
users_emails = [t.email for t in instance.users.iterator()]
if users_emails:
send_notification(
f'New DREF: {instance.title}',
f'{new_or_updated} DREF: {instance.title}',
users_emails,
render_to_string('email/dref/dref.html', email_context),
'New DREF'
f'{new_or_updated} DREF'
)
return email_context

0 comments on commit 2d35f82

Please sign in to comment.