@@ -32,6 +32,10 @@ def add_arguments(self, parser):
32
32
help = "Use this session config and only send emails to people in this session" ,
33
33
)
34
34
35
+ parser .add_argument (
36
+ "--test_email" , action = "store" , help = "send a test email to this address"
37
+ )
38
+
35
39
def get_config (self , session ):
36
40
if settings .WELCOME_EMAIL .get (session ):
37
41
return settings .WELCOME_EMAIL [session ]
@@ -44,25 +48,34 @@ def handle(self, *args, **kwargs):
44
48
f"{ YELLOW } Not sending emails. Call with --send_emails to send{ NOBOLD } "
45
49
)
46
50
47
- users = Marker .objects .filter (send_welcome_email = True ).select_related ("user" )
48
-
49
- if kwargs ["stage" ]:
50
- try :
51
- rt = ResponseType .objects .get (type = kwargs ["stage" ])
52
- users = users .filter (response_type = rt )
53
- except ResponseType .NotFoundException :
54
- self .stderr .write (f"{ YELLOW } No such stage: { kwargs ['stage' ]} { NOBOLD } " )
55
- return
51
+ if kwargs ["test_email" ]:
52
+ users = Marker .objects .filter (
53
+ user__email = kwargs ["test_email" ]
54
+ ).select_related ("user" )
55
+ else :
56
+ users = Marker .objects .filter (send_welcome_email = True ).select_related (
57
+ "user"
58
+ )
56
59
57
- if kwargs ["session" ]:
58
- try :
59
- session = MarkingSession .objects .get (label = kwargs ["session" ])
60
- users = users .filter (marking_session = session )
61
- except ResponseType .NotFoundException :
62
- self .stderr .write (
63
- f"{ YELLOW } No such session: { kwargs ['session' ]} { NOBOLD } "
64
- )
65
- return
60
+ if kwargs ["stage" ]:
61
+ try :
62
+ rt = ResponseType .objects .get (type = kwargs ["stage" ])
63
+ users = users .filter (response_type = rt )
64
+ except ResponseType .NotFoundException :
65
+ self .stderr .write (
66
+ f"{ YELLOW } No such stage: { kwargs ['stage' ]} { NOBOLD } "
67
+ )
68
+ return
69
+
70
+ if kwargs ["session" ]:
71
+ try :
72
+ session = MarkingSession .objects .get (label = kwargs ["session" ])
73
+ users = users .filter (marking_session = session )
74
+ except ResponseType .NotFoundException :
75
+ self .stderr .write (
76
+ f"{ YELLOW } No such session: { kwargs ['session' ]} { NOBOLD } "
77
+ )
78
+ return
66
79
67
80
config = self .get_config (kwargs ["session" ])
68
81
0 commit comments