-
Couldn't load subscription status.
- Fork 350
[ENG-9005] Fix/update v2 subscriptions #11329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ENG-9005] Fix/update v2 subscriptions #11329
Conversation
|
|
||
| return NotificationSubscription.objects.filter(user=self.request.user).annotate( | ||
| return NotificationSubscription.objects.filter( | ||
| notification_type__in=[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Main issue was we were pulling from types of subscription that weren't coded for legacy susbscriptions, this filters the types of new notification that are editable now. Only those 3 now that comments and mentions aren't subscription types.
| event_name=Case( | ||
| When( | ||
| notification_type__name=NotificationType.Type.NODE_FILES_UPDATED.value, | ||
| notification_type=NotificationType.Type.USER_FILE_UPDATED.instance, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improvement performance and Value( for correctness.
| def notification(self, user): | ||
| return NotificationSubscriptionFactory(user=user) | ||
| return NotificationSubscriptionFactory( | ||
| notification_type=NotificationType.Type.USER_FILE_UPDATED.instance, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests weren't quite right because they didn't use the subscribed object attribute, only type and user.
| return NotificationSubscriptionFactory( | ||
| notification_type=NotificationType.Type.NODE_FILES_UPDATED.instance, | ||
| subscribed_object=node, | ||
| notification_type=NotificationType.Type.NODE_FILE_UPDATED.instance, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo in FILE(S) and same as above.
43f53d6 to
caca24c
Compare
| match getattr(ct, 'model', None): | ||
| case 'preprintprovider' | 'collectionprovider' | 'registrationprovider': | ||
| # Providers: use subscribed_object._id (which is the provider short name, e.g. 'mindrxiv') | ||
| match self.notification_type.name: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just changed for clarity and correctness.
| return obj.absolute_api_v2_url | ||
|
|
||
| def update(self, instance, validated_data): | ||
| instance.message_frequency = validated_data.get['frequency'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strange this wasn't effected by tests, but now it works in test_subscription_detail_patch
| @property | ||
| def absolute_api_v2_url(self): | ||
| from api.base.utils import absolute_reverse | ||
| return absolute_reverse('institutions:institution-detail', kwargs={'institution_id': self._id, 'version': 'v2'}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is another thing that should have broken tests, but didn't.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
0b7fe79
into
CenterForOpenScience:feature/notification-refactor-p2-s
Purpose
Fix subscription legacy compatibility issues with v2 API
Changes
QA Notes
Please make verification statements inspired by your code and what your code touches.
What are the areas of risk?
Any concerns/considerations/questions that development raised?
Documentation
Side Effects
Ticket
https://openscience.atlassian.net/browse/ENG-9005