forked from CenterForOpenScience/osf.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CR][ENG-5681] Great Big Python Upgrade (CenterForOpenScience#10648)
- Bump base python version from py3.6 to py3.12. - Switch to using poetry for dependency management - Bump most (not all) dependencies to their maximum version as of mid-March. - Significantly update Dockerfile - Upgrade Django to v4.2 - Generate test summary reports in CI --------- Co-authored-by: Oleh Paduchak <opaduchak@exoft.net> Co-authored-by: Mariia Lychko <lychko.mariia@gmail.com> Co-authored-by: Longze Chen <cslzchen@gmail.com>
- Loading branch information
1 parent
0b6a3da
commit 15fb8af
Showing
19 changed files
with
397 additions
and
275 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# Allow for optional timeout parameter. | ||
# https://github.com/IQSS/dataverse-client-python/pull/27 | ||
git+https://github.com/CenterForOpenScience/dataverse-client-python.git@2b3827578048e6df3818f82381c7ea9a2395e526 # branch is feature/dv-client-updates | ||
git+https://github.com/CenterForOpenScience/dataverse-client-python.git@feature/dv-client-updates |
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,2 +1,2 @@ | ||
# up-to-date with mendeley's master + add folder support and future dep updates | ||
git+https://github.com/CenterForOpenScience/mendeley-python-sdk.git@be8a811fa6c3b105d9f5c656cabb6b1ba855ed5b # branch is feature/osf-dep-updates | ||
git+https://github.com/CenterForOpenScience/mendeley-python-sdk.git@feature/osf-dep-updates |
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,8 @@ | ||
from django.urls import re_path | ||
from admin.notifications import views | ||
|
||
app_name = 'notifications' | ||
|
||
urlpatterns = [ | ||
re_path(r'^$', views.handle_duplicate_notifications, name='handle_duplicate_notifications'), | ||
] |
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,32 @@ | ||
from django.contrib.auth.decorators import user_passes_test | ||
from django.shortcuts import render, redirect | ||
from admin.base.utils import osf_staff_check | ||
from osf.models.notifications import NotificationSubscription | ||
from django.db.models import Count | ||
|
||
@user_passes_test(osf_staff_check) | ||
def handle_duplicate_notifications(request): | ||
duplicates = NotificationSubscription.objects.values('user', 'node', 'event_name').annotate(count=Count('id')).filter(count__gt=1) | ||
|
||
detailed_duplicates = [] | ||
for dup in duplicates: | ||
notifications = NotificationSubscription.objects.filter(user=dup['user'], node=dup['node'], event_name=dup['event_name']) | ||
for notification in notifications: | ||
detailed_duplicates.append({ | ||
'id': notification.id, | ||
'user': notification.user, | ||
'node': notification.node, | ||
'event_name': notification.event_name, | ||
'created': notification.created, | ||
'count': dup['count'] | ||
}) | ||
|
||
context = {'duplicates': detailed_duplicates} | ||
|
||
if request.method == 'POST': | ||
selected_ids = request.POST.getlist('selected_notifications') | ||
NotificationSubscription.objects.filter(id__in=selected_ids).delete() | ||
context['message'] = 'Selected duplicate notifications have been deleted.' | ||
return redirect('notifications:handle_duplicate_notifications') | ||
|
||
return render(request, 'handle_duplicate_notifications.html', context) |
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,54 @@ | ||
{% extends "base.html" %} | ||
{% load render_bundle from webpack_loader %} | ||
{% load static %} | ||
|
||
{% block title %} | ||
<title>Duplicate Notifications</title> | ||
{% endblock title %} | ||
|
||
{% block content %} | ||
<h2>Duplicate Notifications</h2> | ||
|
||
{% if message %} | ||
<div class="alert alert-success"> | ||
{{ message }} | ||
</div> | ||
{% endif %} | ||
|
||
{% if duplicates %} | ||
<form method="post"> | ||
{% csrf_token %} | ||
<table class="table table-striped table-hover table-responsive"> | ||
<thead> | ||
<tr> | ||
<th>Select</th> | ||
<th>User</th> | ||
<th>Node</th> | ||
<th>Event Name</th> | ||
<th>Created</th> | ||
<th>Count</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for notification in duplicates %} | ||
<tr> | ||
<td><input type="checkbox" name="selected_notifications" value="{{ notification.id }}"></td> | ||
<td>{{ notification.user }}</td> | ||
<td>{{ notification.node }}</td> | ||
<td>{{ notification.event_name }}</td> | ||
<td>{{ notification.created }}</td> | ||
<td>{{ notification.count }}</td> | ||
</tr> | ||
{% empty %} | ||
<tr> | ||
<td colspan="6">No duplicate notifications found!</td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
<button type="submit" class="btn btn-danger">Delete Selected</button> | ||
</form> | ||
{% else %} | ||
<p>No duplicate notifications found.</p> | ||
{% endif %} | ||
{% endblock content %} |
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
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
# Reference README-docker-compose.md for instructions. | ||
|
||
version: '3.5' | ||
|
||
volumes: | ||
redis_data_vol: | ||
external: false | ||
|
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,27 @@ | ||
from django.core.management.base import BaseCommand | ||
from osf.models.notifications import NotificationSubscription | ||
from osf.models import OSFUser, Node | ||
from django.utils.crypto import get_random_string | ||
from django.utils import timezone | ||
|
||
class Command(BaseCommand): | ||
help = 'Create duplicate notifications for testing' | ||
|
||
def handle(self, *args, **kwargs): | ||
user = OSFUser.objects.first() | ||
node = Node.objects.first() | ||
event_name = 'file_added' | ||
|
||
for _ in range(3): | ||
unique_id = get_random_string(length=32) | ||
notification = NotificationSubscription.objects.create( | ||
user=user, | ||
node=node, | ||
event_name=event_name, | ||
_id=unique_id, | ||
created=timezone.now() | ||
) | ||
notification.email_transactional.add(user) | ||
notification.save() | ||
|
||
self.stdout.write(self.style.SUCCESS('Successfully created duplicate notifications')) |
Oops, something went wrong.