@@ -1133,27 +1133,31 @@ def set_sticky_students(self, users: "Sequence[AbstractBaseUser]") -> None:
1133
1133
self .add_user (user , force = True )
1134
1134
1135
1135
old_sticky_students = self .sticky_students .all ()
1136
- self .sticky_students .set (users )
1137
1136
1138
1137
# note: this will send separate emails to each student for each activity they are stickied in
1139
1138
new_stickied_students = [user .notification_email for user in users if user not in old_sticky_students ]
1140
1139
unstickied_students = [user .notification_email for user in old_sticky_students if user not in users ]
1141
- email_send_task .delay (
1142
- "eighth/emails/students_stickied.txt" ,
1143
- "eighth/emails/students_stickied.html" ,
1144
- data = {"activity" : self },
1145
- subject = "You have been stickied into an activity" ,
1146
- emails = new_stickied_students ,
1147
- bcc = True ,
1148
- )
1149
- email_send_task .delay (
1150
- "eighth/emails/students_unstickied.txt" ,
1151
- "eighth/emails/students_unstickied.html" ,
1152
- data = {"activity" : self },
1153
- subject = "You have been unstickied from an activity" ,
1154
- emails = unstickied_students ,
1155
- bcc = True ,
1156
- )
1140
+
1141
+ self .sticky_students .set (users )
1142
+
1143
+ if new_stickied_students :
1144
+ email_send_task .delay (
1145
+ "eighth/emails/students_stickied.txt" ,
1146
+ "eighth/emails/students_stickied.html" ,
1147
+ data = {"activity" : self },
1148
+ subject = "You have been stickied into an activity" ,
1149
+ emails = new_stickied_students ,
1150
+ bcc = True ,
1151
+ )
1152
+ if unstickied_students :
1153
+ email_send_task .delay (
1154
+ "eighth/emails/students_unstickied.txt" ,
1155
+ "eighth/emails/students_unstickied.html" ,
1156
+ data = {"activity" : self },
1157
+ subject = "You have been unstickied from an activity" ,
1158
+ emails = unstickied_students ,
1159
+ bcc = True ,
1160
+ )
1157
1161
1158
1162
@transaction .atomic # This MUST be run in a transaction. Do NOT remove this decorator.
1159
1163
def add_user (
0 commit comments