Skip to content

Commit 7563a8c

Browse files
committed
Add confirmation email
1 parent 90be065 commit 7563a8c

File tree

4 files changed

+71
-1
lines changed

4 files changed

+71
-1
lines changed

backend/api/grants/mutations.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616
from api.permissions import IsAuthenticated
1717
from api.types import BaseErrorType
1818
from conferences.models.conference import Conference
19-
from grants.tasks import notify_new_grant_reply_slack
19+
from grants.tasks import (
20+
notify_new_grant_reply_slack,
21+
send_grant_application_confirmation_email,
22+
)
2023
from grants.models import Grant as GrantModel
2124
from users.models import User
2225

@@ -254,6 +257,8 @@ def send_grant(self, info: Info, input: SendGrantInput) -> SendGrantResult:
254257
},
255258
)
256259

260+
send_grant_application_confirmation_email(instance)
261+
257262
# hack because we return django models
258263
instance.__strawberry_definition__ = Grant.__strawberry_definition__
259264
return instance

backend/grants/tasks.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,3 +171,17 @@ def _new_send_grant_email(
171171

172172
grant.applicant_reply_sent_at = timezone.now()
173173
grant.save()
174+
175+
176+
def send_grant_application_confirmation_email(grant: Grant):
177+
email_template = EmailTemplate.objects.for_conference(
178+
grant.conference
179+
).get_by_identifier(EmailTemplateIdentifier.grant_application_confirmation)
180+
181+
email_template.send_email(
182+
recipient=grant.user,
183+
placeholders={
184+
"user_name": get_name(grant.user, "there"),
185+
},
186+
)
187+
logger.info("Grant application confirmation email sent for grant %s", grant.id)
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Generated by Django 5.1.1 on 2024-11-24 18:58
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
dependencies = [
8+
("notifications", "0017_alter_emailtemplate_identifier"),
9+
]
10+
11+
operations = [
12+
migrations.AlterField(
13+
model_name="emailtemplate",
14+
name="identifier",
15+
field=models.CharField(
16+
choices=[
17+
("proposal_accepted", "Proposal accepted"),
18+
("proposal_rejected", "Proposal rejected"),
19+
("proposal_in_waiting_list", "Proposal in waiting list"),
20+
(
21+
"proposal_scheduled_time_changed",
22+
"Proposal scheduled time changed",
23+
),
24+
("speaker_communication", "Speaker communication"),
25+
("voucher_code", "Voucher code"),
26+
("reset_password", "[System] Reset password"),
27+
(
28+
"grant_application_confirmation",
29+
"Grant application confirmation",
30+
),
31+
("grant_approved", "Grant approved"),
32+
("grant_rejected", "Grant rejected"),
33+
("grant_waiting_list", "Grant waiting list"),
34+
("grant_waiting_list_update", "Grant waiting list update"),
35+
("grant_voucher_code", "Grant voucher code"),
36+
("sponsorship_brochure", "Sponsorship brochure"),
37+
("custom", "Custom"),
38+
],
39+
max_length=200,
40+
verbose_name="identifier",
41+
),
42+
),
43+
]

backend/notifications/models.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ class EmailTemplateIdentifier(models.TextChoices):
2929

3030
reset_password = "reset_password", _("[System] Reset password")
3131

32+
grant_application_confirmation = (
33+
"grant_application_confirmation",
34+
_("Grant application confirmation"),
35+
)
3236
grant_approved = "grant_approved", _("Grant approved")
3337
grant_rejected = "grant_rejected", _("Grant rejected")
3438
grant_waiting_list = "grant_waiting_list", _("Grant waiting list")
@@ -80,6 +84,10 @@ class EmailTemplate(TimeStampedModel):
8084
"proposal_title",
8185
"invitation_url",
8286
],
87+
EmailTemplateIdentifier.grant_application_confirmation: [
88+
*BASE_PLACEHOLDERS,
89+
"user_name",
90+
],
8391
EmailTemplateIdentifier.grant_approved: [
8492
*BASE_PLACEHOLDERS,
8593
"reply_url",

0 commit comments

Comments
 (0)