-
Notifications
You must be signed in to change notification settings - Fork 330
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
B&I release 24.06.0
- Loading branch information
Showing
67 changed files
with
1,786 additions
and
1,357 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from osf.models.notifications import NotificationSubscription | ||
from django.db.models import Count | ||
|
||
def delete_selected_notifications(selected_ids): | ||
NotificationSubscription.objects.filter(id__in=selected_ids).delete() | ||
|
||
def detect_duplicate_notifications(node_id=None): | ||
query = NotificationSubscription.objects.values('_id').annotate(count=Count('_id')).filter(count__gt=1) | ||
if node_id: | ||
query = query.filter(node_id=node_id) | ||
|
||
detailed_duplicates = [] | ||
for dup in query: | ||
notifications = NotificationSubscription.objects.filter( | ||
_id=dup['_id'] | ||
).order_by('created') | ||
|
||
for notification in notifications: | ||
detailed_duplicates.append({ | ||
'id': notification.id, | ||
'_id': notification._id, | ||
'event_name': notification.event_name, | ||
'created': notification.created, | ||
'count': dup['count'], | ||
'email_transactional': [u._id for u in notification.email_transactional.all()], | ||
'email_digest': [u._id for u in notification.email_digest.all()], | ||
'none': [u._id for u in notification.none.all()] | ||
}) | ||
|
||
return detailed_duplicates |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,33 @@ | ||
from django import forms | ||
|
||
from osf.models import Preprint | ||
|
||
from osf.utils.workflows import ReviewStates | ||
|
||
class ChangeProviderForm(forms.ModelForm): | ||
class Meta: | ||
model = Preprint | ||
fields = ('provider',) | ||
|
||
|
||
class MachineStateForm(forms.ModelForm): | ||
class Meta: | ||
model = Preprint | ||
fields = ('machine_state',) | ||
|
||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
|
||
if not self.instance.is_public: | ||
self.fields['machine_state'].widget.attrs['disabled'] = 'disabled' | ||
else: | ||
if self.instance.machine_state == ReviewStates.INITIAL.db_name: | ||
self.fields['machine_state'].choices = [ | ||
(ReviewStates.INITIAL.value, ReviewStates.INITIAL.value), | ||
(ReviewStates.PENDING.value, ReviewStates.PENDING.value), | ||
] | ||
else: | ||
# Disabled Option you are on | ||
self.fields['machine_state'].widget.attrs['disabled'] = 'disabled' | ||
self.fields['machine_state'].choices = [ | ||
(self.instance.machine_state.title(), self.instance.machine_state) | ||
] |
Oops, something went wrong.