File tree Expand file tree Collapse file tree 3 files changed +54
-9
lines changed Expand file tree Collapse file tree 3 files changed +54
-9
lines changed Original file line number Diff line number Diff line change @@ -1603,6 +1603,25 @@ class ApplicationExtension(models.Model):
1603
1603
)
1604
1604
end_time = models .DateTimeField ()
1605
1605
1606
+ def send_extension_mail (self ):
1607
+ context = {
1608
+ "name" : self .user .first_name ,
1609
+ "application_name" : self .application .name ,
1610
+ "end_time" : self .end_time ,
1611
+ "club" : self .application .club .name ,
1612
+ "url" : (
1613
+ f"https://pennclubs.com/club/{ self .application .club .code } "
1614
+ f"/application/{ self .application .pk } /"
1615
+ ),
1616
+ }
1617
+
1618
+ send_mail_helper (
1619
+ name = "application_extension" ,
1620
+ subject = f"Application Extension for { self .application .name } " ,
1621
+ emails = [self .user .email ],
1622
+ context = context ,
1623
+ )
1624
+
1606
1625
class Meta :
1607
1626
unique_together = (("user" , "application" ),)
1608
1627
Original file line number Diff line number Diff line change @@ -2476,15 +2476,14 @@ def validate(self, data):
2476
2476
if not application :
2477
2477
raise serializers .ValidationError ("Invalid application id!" )
2478
2478
2479
- if (
2480
- (
2481
- not self .instance
2482
- or (username and self .instance .user .username != username )
2483
- )
2484
- and ApplicationExtension .objects .filter (
2485
- user = user , application = application
2486
- ).exists ()
2487
- ):
2479
+ application_exists = ApplicationExtension .objects .filter (
2480
+ user = user , application = application
2481
+ ).exists ()
2482
+ modify_username = not self .instance or (
2483
+ username and self .instance .user .username != username
2484
+ )
2485
+
2486
+ if modify_username and application_exists :
2488
2487
raise serializers .ValidationError (
2489
2488
"An extension for this user and application already exists!"
2490
2489
)
@@ -2500,6 +2499,11 @@ def validate(self, data):
2500
2499
2501
2500
return data
2502
2501
2502
+ def save (self ):
2503
+ extension_obj = super ().save ()
2504
+ extension_obj .send_extension_mail ()
2505
+ return extension_obj
2506
+
2503
2507
2504
2508
class ApplicationSubmissionSerializer (serializers .ModelSerializer ):
2505
2509
committee = ApplicationCommitteeSerializer (required = False , read_only = True )
Original file line number Diff line number Diff line change
1
+ <!-- TYPES:
2
+ name:
3
+ type: string
4
+ club:
5
+ type: string
6
+ application_name:
7
+ type: string
8
+ end_time:
9
+ type: string
10
+ url:
11
+ type: string
12
+ -->
13
+ {% extends 'emails/base.html' %}
14
+
15
+ {% block content %}
16
+ < h2 > Application Extension for {{ application_name }}</ h2 >
17
+ < p style ="font-size: 1.2em; "> Hello {{ name }},</ p >
18
+ < p style ="font-size: 1.2em; "> You have been granted an extension for {{ application_name }} by the officers of {{ club }} on Penn Clubs:</ p >
19
+ < p style ="font-size: 1.2em; "> The updated deadline to submit your application is {{ end_time }}. You can apply using the button below.</ p >
20
+ < a style ="text-decoration: none; padding: 5px 20px; font-size: 1.5em; margin-top: 25px; color: white; background-color: green; border-radius: 3px; font-weight: bold "
21
+ href ="{{ url }} "> Apply</ a >
22
+ {% endblock %}
You can’t perform that action at this time.
0 commit comments