@@ -24,11 +24,11 @@ def subscribe_creator(resource):
2424 if user .is_registered :
2525 NotificationSubscription .objects .get_or_create (
2626 user = user ,
27- notification_type__name = NotificationType .Type .USER_FILE_UPDATED ,
27+ notification_type = NotificationType .objects . get ( name = NotificationType . Type .USER_FILE_UPDATED ) ,
2828 )
2929 NotificationSubscription .objects .get_or_create (
3030 user = user ,
31- notification_type__name = NotificationType .Type .FILE_UPDATED ,
31+ notification_type = NotificationType .objects . get ( name = NotificationType . Type .FILE_UPDATED ) ,
3232 object_id = resource .id ,
3333 content_type = ContentType .objects .get_for_model (resource )
3434 )
@@ -45,11 +45,11 @@ def subscribe_contributor(resource, contributor, auth=None, *args, **kwargs):
4545 if contributor .is_registered :
4646 NotificationSubscription .objects .get_or_create (
4747 user = contributor ,
48- notification_type__name = NotificationType .Type .USER_FILE_UPDATED ,
48+ notification_type = NotificationType .objects . get ( name = NotificationType . Type .USER_FILE_UPDATED ) ,
4949 )
5050 NotificationSubscription .objects .get_or_create (
5151 user = contributor ,
52- notification_type__name = NotificationType .Type .FILE_UPDATED ,
52+ notification_type = NotificationType .objects . get ( name = NotificationType . Type .FILE_UPDATED ) ,
5353 object_id = resource .id ,
5454 content_type = ContentType .objects .get_for_model (resource )
5555 )
@@ -58,15 +58,10 @@ def subscribe_contributor(resource, contributor, auth=None, *args, **kwargs):
5858def subscribe_confirmed_user (user ):
5959 NotificationSubscription = apps .get_model ('osf.NotificationSubscription' )
6060 NotificationType = apps .get_model ('osf.NotificationType' )
61- user_events = [
62- NotificationType .Type .USER_FILE_UPDATED ,
63- NotificationType .Type .USER_REVIEWS ,
64- ]
65- for user_event in user_events :
66- NotificationSubscription .objects .get_or_create (
67- user = user ,
68- notification_type__name = user_event
69- )
61+ NotificationSubscription .objects .get_or_create (
62+ user = user ,
63+ notification_type = NotificationType .objects .get (name = NotificationType .Type .USER_FILE_UPDATED )
64+ )
7065
7166@privacy_set_public .connect
7267def queue_first_public_project_email (user , node ):
@@ -121,7 +116,7 @@ def reviews_submit_notification_moderators(self, timestamp, context, resource):
121116 else :
122117 context ['message' ] = f'submitted "{ resource .title } ".'
123118 provider_subscription , created = NotificationSubscription .objects .get_or_create (
124- notification_type__name = NotificationType .Type .PROVIDER_NEW_PENDING_SUBMISSIONS ,
119+ notification_type = NotificationType .objects . get ( name = NotificationType . Type .PROVIDER_NEW_PENDING_SUBMISSIONS ) ,
125120 object_id = provider .id ,
126121 content_type = ContentType .objects .get_for_model (provider .__class__ ),
127122 )
0 commit comments