@@ -67,34 +67,34 @@ class NotificationType(TypedDict):
6767 'new_comment_on_response' : {
6868 'notification_app' : 'discussion' ,
6969 'name' : 'new_comment_on_response' ,
70- 'is_core ' : True ,
70+ 'use_app_defaults ' : True ,
7171 'content_template' : _ ('<{p}><{strong}>{replier_name}</{strong}> commented on your response to the post '
7272 '<{strong}>{post_title}</{strong}></{p}>' ),
7373 'content_context' : {
7474 'post_title' : 'Post title' ,
7575 'replier_name' : 'replier name' ,
7676 },
77- 'email_template' : '' ,
77+
7878 'filters' : [FILTER_AUDIT_EXPIRED_USERS_WITH_NO_ROLE ]
7979 },
8080 'new_comment' : {
8181 'notification_app' : 'discussion' ,
8282 'name' : 'new_comment' ,
83- 'is_core ' : True ,
83+ 'use_app_defaults ' : True ,
8484 'content_template' : _ ('<{p}><{strong}>{replier_name}</{strong}> commented on <{strong}>{author_name}'
8585 '</{strong}> response to your post <{strong}>{post_title}</{strong}></{p}>' ),
8686 'content_context' : {
8787 'post_title' : 'Post title' ,
8888 'author_name' : 'author name' ,
8989 'replier_name' : 'replier name' ,
9090 },
91- 'email_template' : '' ,
91+
9292 'filters' : [FILTER_AUDIT_EXPIRED_USERS_WITH_NO_ROLE ]
9393 },
9494 'new_response' : {
9595 'notification_app' : 'discussion' ,
9696 'name' : 'new_response' ,
97- 'is_core ' : True ,
97+ 'use_app_defaults ' : True ,
9898 'content_template' : _ ('<{p}><{strong}>{replier_name}</{strong}> responded to your '
9999 'post <{strong}>{post_title}</{strong}></{p}>' ),
100100 'grouped_content_template' : _ ('<{p}><{strong}>{replier_name}</{strong}> and others have responded to your post '
@@ -103,13 +103,13 @@ class NotificationType(TypedDict):
103103 'post_title' : 'Post title' ,
104104 'replier_name' : 'replier name' ,
105105 },
106- 'email_template' : '' ,
106+
107107 'filters' : [FILTER_AUDIT_EXPIRED_USERS_WITH_NO_ROLE ]
108108 },
109109 'new_discussion_post' : {
110110 'notification_app' : 'discussion' ,
111111 'name' : 'new_discussion_post' ,
112- 'is_core' : False ,
112+
113113 'info' : '' ,
114114 'web' : False ,
115115 'email' : False ,
@@ -123,13 +123,13 @@ class NotificationType(TypedDict):
123123 'post_title' : 'Post title' ,
124124 'username' : 'Post author name' ,
125125 },
126- 'email_template' : '' ,
126+
127127 'filters' : [FILTER_AUDIT_EXPIRED_USERS_WITH_NO_ROLE ]
128128 },
129129 'new_question_post' : {
130130 'notification_app' : 'discussion' ,
131131 'name' : 'new_question_post' ,
132- 'is_core' : False ,
132+
133133 'info' : '' ,
134134 'web' : False ,
135135 'email' : False ,
@@ -141,15 +141,13 @@ class NotificationType(TypedDict):
141141 'post_title' : 'Post title' ,
142142 'username' : 'Post author name' ,
143143 },
144- 'email_template' : '' ,
144+
145145 'filters' : [FILTER_AUDIT_EXPIRED_USERS_WITH_NO_ROLE ]
146146 },
147147 'response_on_followed_post' : {
148148 'notification_app' : 'discussion' ,
149149 'name' : 'response_on_followed_post' ,
150- 'is_core' : True ,
151- 'info' : '' ,
152- 'non_editable' : [],
150+ 'use_app_defaults' : True ,
153151 'content_template' : _ ('<{p}><{strong}>{replier_name}</{strong}> responded to a post you’re following: '
154152 '<{strong}>{post_title}</{strong}></{p}>' ),
155153 'grouped_content_template' : _ ('<{p}><{strong}>{replier_name}</{strong}> and others responded to a post you’re '
@@ -158,15 +156,13 @@ class NotificationType(TypedDict):
158156 'post_title' : 'Post title' ,
159157 'replier_name' : 'replier name' ,
160158 },
161- 'email_template' : '' ,
159+
162160 'filters' : [FILTER_AUDIT_EXPIRED_USERS_WITH_NO_ROLE ]
163161 },
164162 'comment_on_followed_post' : {
165163 'notification_app' : 'discussion' ,
166164 'name' : 'comment_on_followed_post' ,
167- 'is_core' : True ,
168- 'info' : '' ,
169- 'non_editable' : [],
165+ 'use_app_defaults' : True ,
170166 'content_template' : _ ('<{p}><{strong}>{replier_name}</{strong}> commented on <{strong}>{author_name}'
171167 '</{strong}> response in a post you’re following <{strong}>{post_title}'
172168 '</{strong}></{p}>' ),
@@ -175,13 +171,13 @@ class NotificationType(TypedDict):
175171 'author_name' : 'author name' ,
176172 'replier_name' : 'replier name' ,
177173 },
178- 'email_template' : '' ,
174+
179175 'filters' : [FILTER_AUDIT_EXPIRED_USERS_WITH_NO_ROLE ]
180176 },
181177 'content_reported' : {
182178 'notification_app' : 'discussion' ,
183179 'name' : 'content_reported' ,
184- 'is_core' : False ,
180+
185181 'info' : '' ,
186182 'web' : True ,
187183 'email' : True ,
@@ -196,42 +192,38 @@ class NotificationType(TypedDict):
196192 'author_name' : 'author name' ,
197193 'replier_name' : 'replier name' ,
198194 },
199- 'email_template' : '' ,
195+
200196 'visible_to' : [FORUM_ROLE_ADMINISTRATOR , FORUM_ROLE_MODERATOR , FORUM_ROLE_COMMUNITY_TA ]
201197 },
202198 'response_endorsed_on_thread' : {
203199 'notification_app' : 'discussion' ,
204200 'name' : 'response_endorsed_on_thread' ,
205- 'is_core' : True ,
206- 'info' : '' ,
207- 'non_editable' : [],
201+ 'use_app_defaults' : True ,
208202 'content_template' : _ ('<{p}><{strong}>{replier_name}\' s</{strong}> response has been endorsed in your post '
209203 '<{strong}>{post_title}</{strong}></{p}>' ),
210204 'content_context' : {
211205 'post_title' : 'Post title' ,
212206 'replier_name' : 'replier name' ,
213207 },
214- 'email_template' : '' ,
208+
215209 'filters' : [FILTER_AUDIT_EXPIRED_USERS_WITH_NO_ROLE ]
216210 },
217211 'response_endorsed' : {
218212 'notification_app' : 'discussion' ,
219213 'name' : 'response_endorsed' ,
220- 'is_core' : True ,
221- 'info' : '' ,
222- 'non_editable' : [],
214+ 'use_app_defaults' : True ,
223215 'content_template' : _ ('<{p}>Your response has been endorsed on the post <{strong}>{post_title}</{strong}></{'
224216 'p}>' ),
225217 'content_context' : {
226218 'post_title' : 'Post title' ,
227219 },
228- 'email_template' : '' ,
220+
229221 'filters' : [FILTER_AUDIT_EXPIRED_USERS_WITH_NO_ROLE ]
230222 },
231223 'course_updates' : {
232224 'notification_app' : 'updates' ,
233225 'name' : 'course_updates' ,
234- 'is_core' : False ,
226+
235227 'info' : '' ,
236228 'web' : True ,
237229 'email' : True ,
@@ -242,13 +234,13 @@ class NotificationType(TypedDict):
242234 'content_context' : {
243235 'course_update_content' : 'Course update' ,
244236 },
245- 'email_template' : '' ,
237+
246238 'filters' : [FILTER_AUDIT_EXPIRED_USERS_WITH_NO_ROLE ]
247239 },
248240 'ora_staff_notifications' : {
249241 'notification_app' : 'grading' ,
250242 'name' : 'ora_staff_notifications' ,
251- 'is_core' : False ,
243+
252244 'info' : 'Notifications for when a submission is made for ORA that includes staff grading step.' ,
253245 'web' : True ,
254246 'email' : False ,
@@ -262,14 +254,14 @@ class NotificationType(TypedDict):
262254 'content_context' : {
263255 'ora_name' : 'Name of ORA in course' ,
264256 },
265- 'email_template' : '' ,
257+
266258 'filters' : [FILTER_AUDIT_EXPIRED_USERS_WITH_NO_ROLE ],
267259 'visible_to' : [CourseStaffRole .ROLE , CourseInstructorRole .ROLE ]
268260 },
269261 'ora_grade_assigned' : {
270262 'notification_app' : 'grading' ,
271263 'name' : 'ora_grade_assigned' ,
272- 'is_core' : False ,
264+
273265 'info' : '' ,
274266 'web' : True ,
275267 'email' : True ,
@@ -283,13 +275,13 @@ class NotificationType(TypedDict):
283275 'points_earned' : 'Points earned' ,
284276 'points_possible' : 'Points possible' ,
285277 },
286- 'email_template' : '' ,
278+
287279 'filters' : [FILTER_AUDIT_EXPIRED_USERS_WITH_NO_ROLE ],
288280 },
289281 'new_instructor_all_learners_post' : {
290282 'notification_app' : 'discussion' ,
291283 'name' : 'new_instructor_all_learners_post' ,
292- 'is_core' : False ,
284+
293285 'info' : '' ,
294286 'web' : True ,
295287 'email' : True ,
@@ -301,7 +293,7 @@ class NotificationType(TypedDict):
301293 'content_context' : {
302294 'post_title' : 'Post title' ,
303295 },
304- 'email_template' : '' ,
296+
305297 'filters' : [FILTER_AUDIT_EXPIRED_USERS_WITH_NO_ROLE ]
306298 },
307299}
@@ -324,16 +316,16 @@ class NotificationApp(TypedDict):
324316 enabled : bool
325317 # Description to be displayed about core notifications for this app.
326318 # This string should be wrapped in the gettext_lazy function (imported as `_`) to support translation.
327- core_info : str
319+ info : str
328320 # Set to True to enable delivery for associated core notifications on web.
329- core_web : bool
321+ web : bool
330322 # Set to True to enable delivery for associated core notifications via emails.
331- core_email : bool
323+ email : bool
332324 # Set to True to enable delivery for associated core notifications via push notifications.
333325 # NOTE: push notifications are not implemented yet
334- core_push : bool
326+ push : bool
335327 # How often email notifications are sent for associated core notifications.
336- core_email_cadence : Literal [EmailCadence .DAILY , EmailCadence .WEEKLY , EmailCadence .IMMEDIATELY , EmailCadence .NEVER ]
328+ email_cadence : Literal [EmailCadence .DAILY , EmailCadence .WEEKLY , EmailCadence .IMMEDIATELY , EmailCadence .NEVER ]
337329 # Items in the list represent core notification delivery channels
338330 # where the user is blocked from changing from what is defined for the app here
339331 # (see `core_web`, `core_email`, and `core_push` above).
@@ -344,30 +336,30 @@ class NotificationApp(TypedDict):
344336_COURSE_NOTIFICATION_APPS : dict [str , NotificationApp ] = {
345337 'discussion' : {
346338 'enabled' : True ,
347- 'core_info ' : _ ('Notifications for responses and comments on your posts, and the ones you’re '
348- 'following, including endorsements to your responses and on your posts.' ),
349- 'core_web ' : True ,
350- 'core_email ' : True ,
351- 'core_push ' : True ,
352- 'core_email_cadence ' : EmailCadence .DAILY ,
339+ 'info ' : _ ('Notifications for responses and comments on your posts, and the ones you’re '
340+ 'following, including endorsements to your responses and on your posts.' ),
341+ 'web ' : True ,
342+ 'email ' : True ,
343+ 'push ' : True ,
344+ 'email_cadence ' : EmailCadence .DAILY ,
353345 'non_editable' : []
354346 },
355347 'updates' : {
356348 'enabled' : True ,
357- 'core_info ' : _ ('Notifications for new announcements and updates from the course team.' ),
358- 'core_web ' : True ,
359- 'core_email ' : True ,
360- 'core_push ' : True ,
361- 'core_email_cadence ' : EmailCadence .DAILY ,
349+ 'info ' : _ ('Notifications for new announcements and updates from the course team.' ),
350+ 'web ' : True ,
351+ 'email ' : True ,
352+ 'push ' : True ,
353+ 'email_cadence ' : EmailCadence .DAILY ,
362354 'non_editable' : []
363355 },
364356 'grading' : {
365357 'enabled' : True ,
366- 'core_info ' : _ ('Notifications for submission grading.' ),
367- 'core_web ' : True ,
368- 'core_email ' : True ,
369- 'core_push ' : True ,
370- 'core_email_cadence ' : EmailCadence .DAILY ,
358+ 'info ' : _ ('Notifications for submission grading.' ),
359+ 'web ' : True ,
360+ 'email ' : True ,
361+ 'push ' : True ,
362+ 'email_cadence ' : EmailCadence .DAILY ,
371363 'non_editable' : []
372364 },
373365}
@@ -405,7 +397,7 @@ def get_core_and_non_core_notification_types(
405397 core_notification_types = []
406398 non_core_notification_types = []
407399 for notification_type in notification_types :
408- if notification_type .get ('is_core ' , None ):
400+ if notification_type .get ('use_app_defaults ' , None ):
409401 core_notification_types .append (notification_type )
410402 else :
411403 non_core_notification_types .append (notification_type )
@@ -450,10 +442,10 @@ def add_core_notification_preference(self, notification_app_attrs, notification_
450442 Adds core notification preference for the given notification app.
451443 """
452444 notification_types ['core' ] = {
453- 'web' : notification_app_attrs .get ('core_web ' , False ),
454- 'email' : False if email_opt_out else notification_app_attrs .get ('core_email ' , False ),
455- 'push' : notification_app_attrs .get ('core_push ' , False ),
456- 'email_cadence' : notification_app_attrs .get ('core_email_cadence ' , 'Daily' ),
445+ 'web' : notification_app_attrs .get ('web ' , False ),
446+ 'email' : False if email_opt_out else notification_app_attrs .get ('email ' , False ),
447+ 'push' : notification_app_attrs .get ('push ' , False ),
448+ 'email_cadence' : notification_app_attrs .get ('email_cadence ' , 'Daily' ),
457449 }
458450
459451 def get_notification_app_preferences (self , email_opt_out = False ):
@@ -533,3 +525,17 @@ def get_default_values_of_preference(notification_app, notification_type):
533525 if notification_type in core_notification_types :
534526 return notification_types .get ('core' , {})
535527 return notification_types .get (notification_type , {})
528+
529+
530+ def get_default_values_of_preferences ():
531+ """
532+ Returns default preferences for all notification apps
533+ """
534+ preferences = {}
535+ for name , values in COURSE_NOTIFICATION_TYPES .items ():
536+ if values .get ('use_app_defaults' , None ):
537+ app_defaults = COURSE_NOTIFICATION_APPS [values ['notification_app' ]]
538+ preferences [name ] = {** app_defaults , ** values }
539+ else :
540+ preferences [name ] = {** values }
541+ return preferences
0 commit comments