Skip to content

Commit

Permalink
Merge branch 'feature/b-and-i-24-14' of https://github.com/CenterForO…
Browse files Browse the repository at this point in the history
…penScience/osf.io into fix-preprint-emails

* 'feature/b-and-i-24-14' of https://github.com/CenterForOpenScience/osf.io:
  Make resubmissions more like submissions (CenterForOpenScience#10709)
  renamed files with travis in their names
  fixed case where it was more appropriate
  removed all travis mentions and replaced them with CI
  [ENG-2562] add system tags to users created via institutional sign up system (CenterForOpenScience#10696)
  refactor handle_duplicate_notifications and add tests
  Shorten lines; rename script for test clarity
  fix flake8 errors
  add admin screen to manage duplicate notifications
  [ENG-2814] Allow Read-only and Read/Write contributors to view a project's draft registrations (CenterForOpenScience#10660)
  [CR][ENG-5997] merge develop into b-and-i branch (CenterForOpenScience#10691)
  add exception handling in case state doesn't change
  [ENG-4527] Fix citation to use registered date (CenterForOpenScience#10678)
  restrict state changes more and allow no-ops
  split apart change provider views from general preprint view and machine_state change viewa
  Re-add permissions changes for files on withdrawn registrations (CenterForOpenScience#10671)
  [ENG-4903] Fixes issue with email confirmation links failing due to database congestion (CenterForOpenScience#10662)

# Conflicts:
#	osf/utils/notifications.py
#	website/templates/emails/reviews_resubmission_confirmation.html.mako
  • Loading branch information
John Tordoff committed Aug 21, 2024
2 parents 6822ad9 + 6335dc3 commit 8a19a14
Show file tree
Hide file tree
Showing 58 changed files with 1,520 additions and 1,306 deletions.
6 changes: 3 additions & 3 deletions .github/actions/start-build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ runs:
- name: Copy Settings
shell: bash
run: |
cp website/settings/local-travis.py website/settings/local.py
cp api/base/settings/local-travis.py api/base/settings/local.py
cp website/settings/local-ci.py website/settings/local.py
cp api/base/settings/local-ci.py api/base/settings/local.py
mkdir -p ~/preprints
touch ~/preprints/index.html
- name: PIP install
Expand All @@ -41,7 +41,7 @@ runs:
shell: bash
run: |
# bumped psycopg to match requirements.txt, as otherwise build would fail
poetry run python3 -m invoke travis-addon-settings
poetry run python3 -m invoke ci-addon-settings
pip uninstall uritemplate.py --yes
# use yarn add --exact to match versions in yarn.lock w/o installing all deps
yarn add --exact bower@^1.8.8
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
- uses: actions/checkout@v2
- uses: ./.github/actions/start-build
- name: Run tests
run: poetry run python3 -m invoke test-travis-addons -n 1 --junit
run: poetry run python3 -m invoke test-ci-addons -n 1 --junit
- name: Upload report
if: (github.event_name != 'pull_request') && (success() || failure()) # run this step even if previous step failed
uses: ./.github/actions/gen-report
Expand All @@ -79,7 +79,7 @@ jobs:
- uses: actions/checkout@v2
- uses: ./.github/actions/start-build
- name: Run tests
run: poetry run python3 -m invoke test-travis-website -n 1 --junit
run: poetry run python3 -m invoke test-ci-website -n 1 --junit
- name: Upload report
if: (github.event_name != 'pull_request') && (success() || failure()) # run this step even if previous step failed
uses: ./.github/actions/gen-report
Expand Down Expand Up @@ -108,7 +108,7 @@ jobs:
- name: NVM & yarn install
run: poetry run python3 -m invoke assets --dev
- name: Run test
run: poetry run python3 -m invoke test-travis-api1-and-js -n 1 --junit
run: poetry run python3 -m invoke test-ci-api1-and-js -n 1 --junit
- name: Upload report
if: (github.event_name != 'pull_request') && (success() || failure()) # run this step even if previous step failed
uses: ./.github/actions/gen-report
Expand All @@ -135,7 +135,7 @@ jobs:
- uses: actions/checkout@v2
- uses: ./.github/actions/start-build
- name: Run tests
run: poetry run python3 -m invoke test-travis-api2 -n 1 --junit
run: poetry run python3 -m invoke test-ci-api2 -n 1 --junit
- name: Upload report
if: (github.event_name != 'pull_request') && (success() || failure()) # run this step even if previous step failed
uses: ./.github/actions/gen-report
Expand Down Expand Up @@ -163,7 +163,7 @@ jobs:
- uses: actions/checkout@v2
- uses: ./.github/actions/start-build
- name: Run tests
run: poetry run python3 -m invoke test-travis-api3-and-osf -n 1 --junit
run: poetry run python3 -m invoke test-ci-api3-and-osf -n 1 --junit
- name: Upload report
if: (github.event_name != 'pull_request') && (success() || failure()) # run this step even if previous step failed
uses: ./.github/actions/gen-report
185 changes: 0 additions & 185 deletions .travis.yml

This file was deleted.

3 changes: 3 additions & 0 deletions addons/base/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,9 @@ def get_authenticated_resource(resource_id):
if resource.deleted:
raise HTTPError(http_status.HTTP_410_GONE, message='Resource has been deleted.')

if getattr(resource, 'is_retracted', False):
raise HTTPError(http_status.HTTP_410_GONE, message='Resource has been retracted.')

return resource


Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions admin/base/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
re_path(r'^schema_responses/', include('admin.schema_responses.urls', namespace='schema_responses')),
re_path(r'^registration_schemas/', include('admin.registration_schemas.urls', namespace='registration_schemas')),
re_path(r'^cedar_metadata_templates/', include('admin.cedar.urls', namespace='cedar_metadata_templates')),
re_path(r'^notifications/', include('admin.notifications.urls', namespace='notifications')),
]),
),
]
Expand Down
8 changes: 8 additions & 0 deletions admin/notifications/urls.py
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'),
]
54 changes: 54 additions & 0 deletions admin/notifications/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
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

def delete_selected_notifications(selected_ids):
NotificationSubscription.objects.filter(id__in=selected_ids).delete()

def detect_duplicate_notifications():
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']
).order_by('created')

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']
})

return detailed_duplicates

def process_duplicate_notifications(request):
detailed_duplicates = detect_duplicate_notifications()

if request.method == 'POST':
selected_ids = request.POST.getlist('selected_notifications')
delete_selected_notifications(selected_ids)
return detailed_duplicates, 'Selected duplicate notifications have been deleted.', True

return detailed_duplicates, '', False

@user_passes_test(osf_staff_check)
def handle_duplicate_notifications(request):
detailed_duplicates, message, is_post = process_duplicate_notifications(request)

context = {'duplicates': detailed_duplicates}
if is_post:
context['message'] = message
return redirect('notifications:handle_duplicate_notifications')

return render(request, 'notifications/handle_duplicate_notifications.html', context)
26 changes: 25 additions & 1 deletion admin/preprints/forms.py
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)
]
2 changes: 2 additions & 0 deletions admin/preprints/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
re_path(r'^known_ham$', views.PreprintKnownHamList.as_view(), name='known-ham'),
re_path(r'^withdrawal_requests$', views.PreprintWithdrawalRequestList.as_view(), name='withdrawal-requests'),
re_path(r'^(?P<guid>[a-z0-9]+)/$', views.PreprintView.as_view(), name='preprint'),
re_path(r'^(?P<guid>[a-z0-9]+)/change_provider/$', views.PreprintProviderChangeView.as_view(), name='preprint-provider'),
re_path(r'^(?P<guid>[a-z0-9]+)/machine_state/$', views.PreprintMachineStateView.as_view(), name='preprint-machine-state'),
re_path(r'^(?P<guid>[a-z0-9]+)/reindex_share_preprint/$', views.PreprintReindexShare.as_view(),
name='reindex-share-preprint'),
re_path(r'^(?P<guid>[a-z0-9]+)/remove_user/(?P<user_id>[a-z0-9]+)/$', views.PreprintRemoveContributorView.as_view(),
Expand Down
Loading

0 comments on commit 8a19a14

Please sign in to comment.