Skip to content

Commit c969bdf

Browse files
Refactor notification type references to use NotificationTypeEnum
1 parent 4d7ed99 commit c969bdf

4 files changed

Lines changed: 24 additions & 24 deletions

osf/management/commands/remove_duplicate_notification_subscriptions_v2.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from django.db import transaction
33
from django.db.models import OuterRef, Exists, Q
44

5-
from osf.models import NotificationSubscription, NotificationType
5+
from osf.models import NotificationSubscription, NotificationType, NotificationTypeEnum
66

77

88
class Command(BaseCommand):
@@ -23,22 +23,22 @@ def handle(self, *args, **options):
2323
self.stdout.write('Finding duplicate NotificationSubscription records…')
2424
digest_type_names = {
2525
# User types
26-
NotificationType.Type.USER_NO_ADDON.value,
26+
NotificationTypeEnum.USER_NO_ADDON.value,
2727
# File types
28-
NotificationType.Type.ADDON_FILE_COPIED.value,
29-
NotificationType.Type.ADDON_FILE_MOVED.value,
30-
NotificationType.Type.ADDON_FILE_RENAMED.value,
31-
NotificationType.Type.FILE_ADDED.value,
32-
NotificationType.Type.FILE_REMOVED.value,
33-
NotificationType.Type.FILE_UPDATED.value,
34-
NotificationType.Type.FOLDER_CREATED.value,
35-
NotificationType.Type.NODE_FILE_UPDATED.value,
36-
NotificationType.Type.USER_FILE_UPDATED.value,
28+
NotificationTypeEnum.ADDON_FILE_COPIED.value,
29+
NotificationTypeEnum.ADDON_FILE_MOVED.value,
30+
NotificationTypeEnum.ADDON_FILE_RENAMED.value,
31+
NotificationTypeEnum.FILE_ADDED.value,
32+
NotificationTypeEnum.FILE_REMOVED.value,
33+
NotificationTypeEnum.FILE_UPDATED.value,
34+
NotificationTypeEnum.FOLDER_CREATED.value,
35+
NotificationTypeEnum.NODE_FILE_UPDATED.value,
36+
NotificationTypeEnum.USER_FILE_UPDATED.value,
3737
# Review types
38-
NotificationType.Type.COLLECTION_SUBMISSION_SUBMITTED.value,
39-
NotificationType.Type.PROVIDER_NEW_PENDING_SUBMISSIONS.value,
40-
NotificationType.Type.PROVIDER_NEW_PENDING_WITHDRAW_REQUESTS.value,
41-
NotificationType.Type.REVIEWS_SUBMISSION_STATUS.value,
38+
NotificationTypeEnum.COLLECTION_SUBMISSION_SUBMITTED.value,
39+
NotificationTypeEnum.PROVIDER_NEW_PENDING_SUBMISSIONS.value,
40+
NotificationTypeEnum.PROVIDER_NEW_PENDING_WITHDRAW_REQUESTS.value,
41+
NotificationTypeEnum.REVIEWS_SUBMISSION_STATUS.value,
4242
}
4343

4444
digest_type_ids = NotificationType.objects.filter(

scripts/remove_after_use/populate_notification_subscriptions_node_file_updated.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
from django.contrib.contenttypes.models import ContentType
1010
from django.db.models import Count, F, OuterRef, Subquery, IntegerField, CharField
1111
from django.db.models.functions import Cast, Coalesce
12-
from osf.models import Node, NotificationSubscription, NotificationType
12+
from osf.models import Node, NotificationSubscription, NotificationTypeEnum
1313

1414

1515
@celery_app.task(name='scripts.remove_after_use.populate_notification_subscriptions_node_file_updated')
1616
def populate_notification_subscriptions_node_file_updated(batch_size: int = 1000):
1717
print('---Starting NODE_FILE_UPDATED subscriptions population script----')
1818
global_start = datetime.now()
1919

20-
node_file_nt = NotificationType.Type.NODE_FILE_UPDATED
20+
node_file_nt = NotificationTypeEnum.NODE_FILE_UPDATED
2121

2222
node_ct = ContentType.objects.get_for_model(Node)
2323

@@ -113,7 +113,7 @@ def populate_notification_subscriptions_node_file_updated(batch_size: int = 1000
113113
def update_notification_subscriptions_node_file_updated():
114114
print('---Starting NODE_FILE_UPDATED subscriptions update script----')
115115

116-
node_file_nt = NotificationType.Type.NODE_FILE_UPDATED
116+
node_file_nt = NotificationTypeEnum.NODE_FILE_UPDATED
117117

118118
updated_start = datetime.now()
119119
updated = (

scripts/remove_after_use/populate_notification_subscriptions_user_global_file_updated.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
from datetime import datetime
1010
from framework.celery_tasks import app as celery_app
1111
from django.contrib.contenttypes.models import ContentType
12-
from osf.models import OSFUser, NotificationSubscription, NotificationType
12+
from osf.models import OSFUser, NotificationSubscription, NotificationTypeEnum
1313

1414
@celery_app.task(name='scripts.remove_after_use.populate_notification_subscriptions_user_global_file_updated')
1515
def populate_notification_subscriptions_user_global_file_updated(per_last_years: int | None= None, batch_size: int = 1000):
1616
print('---Starting USER_FILE_UPDATED subscriptions population script----')
1717
global_start = datetime.now()
1818

19-
user_file_updated_nt = NotificationType.Type.USER_FILE_UPDATED
19+
user_file_updated_nt = NotificationTypeEnum.USER_FILE_UPDATED
2020
user_ct = ContentType.objects.get_for_model(OSFUser)
2121
if per_last_years:
2222
from_date = timezone.now() - relativedelta(years=per_last_years)
@@ -94,7 +94,7 @@ def populate_notification_subscriptions_user_global_file_updated(per_last_years:
9494
def update_notification_subscriptions_user_global_file_updated():
9595
print('---Starting USER_FILE_UPDATED subscriptions updating script----')
9696

97-
user_file_updated_nt = NotificationType.Type.USER_FILE_UPDATED
97+
user_file_updated_nt = NotificationTypeEnum.USER_FILE_UPDATED
9898

9999
update_start = datetime.now()
100100
updated = (

scripts/remove_after_use/populate_notification_subscriptions_user_global_reviews.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
from datetime import datetime
1010
from framework.celery_tasks import app as celery_app
1111
from django.contrib.contenttypes.models import ContentType
12-
from osf.models import OSFUser, NotificationSubscription, NotificationType
12+
from osf.models import OSFUser, NotificationSubscription, NotificationTypeEnum
1313

1414

1515
@celery_app.task(name='scripts.remove_after_use.populate_notification_subscriptions_user_global_reviews')
1616
def populate_notification_subscriptions_user_global_reviews(per_last_years: int | None = None, batch_size: int = 1000):
1717
print('---Starting REVIEWS_SUBMISSION_STATUS subscriptions population script----')
1818
global_start = datetime.now()
1919

20-
review_nt = NotificationType.Type.REVIEWS_SUBMISSION_STATUS
20+
review_nt = NotificationTypeEnum.REVIEWS_SUBMISSION_STATUS
2121
user_ct = ContentType.objects.get_for_model(OSFUser)
2222
if per_last_years:
2323
from_date = timezone.now() - relativedelta(years=per_last_years)
@@ -88,7 +88,7 @@ def populate_notification_subscriptions_user_global_reviews(per_last_years: int
8888
def update_notification_subscriptions_user_global_reviews():
8989
print('---Starting REVIEWS_SUBMISSION_STATUS subscriptions updating script----')
9090

91-
review_nt = NotificationType.Type.REVIEWS_SUBMISSION_STATUS
91+
review_nt = NotificationTypeEnum.REVIEWS_SUBMISSION_STATUS
9292

9393
updated_start = datetime.now()
9494
updated = (

0 commit comments

Comments
 (0)