Skip to content

Commit 613ff26

Browse files
committed
Merge tag '26.2.2' into develop
Hotfix for registration moderation
2 parents 78eabe7 + 4e23670 commit 613ff26

File tree

4 files changed

+21
-9
lines changed

4 files changed

+21
-9
lines changed

api/providers/views.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
WhitelistedSHAREPreprintProvider,
7979
)
8080
from osf.models.action import RegistrationAction, CollectionSubmissionAction
81+
from osf.models.spam import SpamStatus
8182
from osf.registrations.utils import (
8283
BulkRegistrationUpload,
8384
InvalidHeadersError,
@@ -778,6 +779,9 @@ def get_default_queryset(self):
778779

779780
return Registration.objects.filter(
780781
provider=provider,
782+
deleted__isnull=True,
783+
).exclude(
784+
spam_status__in=[SpamStatus.FLAGGED, SpamStatus.SPAM],
781785
).annotate(
782786
revision_state=registration_annotations.REVISION_STATE,
783787
**resource_annotations.make_open_practice_badge_annotations(),

api/registrations/views.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from website.project import signals as project_signals
1010

1111
from osf.models import Registration, OSFUser, RegistrationProvider, OutcomeArtifact, CedarMetadataRecord
12+
from osf.models.spam import SpamStatus
1213
from osf.utils.permissions import WRITE_NODE
1314
from osf.utils.workflows import ApprovalStates
1415

@@ -922,7 +923,10 @@ def get_registration(self):
922923
return registration
923924

924925
def get_default_queryset(self):
925-
return self.get_registration().actions.all()
926+
registration = self.get_registration()
927+
if registration.deleted or registration.spam_status in [SpamStatus.FLAGGED, SpamStatus.SPAM]:
928+
return registration.actions.none()
929+
return registration.actions.all()
926930

927931
def get_queryset(self):
928932
return self.get_queryset_from_request()

scripts/tests/test_populate_new_and_noteworthy.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,29 @@
1+
from unittest import mock
2+
13
from tests.base import OsfTestCase
24
from osf_tests.factories import ProjectFactory
35

46
from osf.models import Node
5-
from website.settings import NEW_AND_NOTEWORTHY_LINKS_NODE
67

78
from scripts import populate_new_and_noteworthy_projects as script
89

10+
TEST_NEW_AND_NOTEWORTHY_GUID = 'nguid'
11+
912

1013
class TestPopulateNewAndNoteworthy(OsfTestCase):
1114

1215
def setUp(self):
1316
super().setUp()
1417

1518
self.new_and_noteworthy_links_node = ProjectFactory()
16-
self.new_and_noteworthy_links_node._id = NEW_AND_NOTEWORTHY_LINKS_NODE
19+
self.new_and_noteworthy_links_node._id = TEST_NEW_AND_NOTEWORTHY_GUID
1720
self.new_and_noteworthy_links_node.save()
1821

19-
self.nn1 = ProjectFactory(is_public=True)
20-
self.nn2 = ProjectFactory(is_public=True)
21-
self.nn3 = ProjectFactory(is_public=True)
22-
self.nn4 = ProjectFactory(is_public=True)
23-
self.nn5 = ProjectFactory(is_public=True)
22+
self.nn1 = ProjectFactory(is_public=True, title='Noteworthy Alpha')
23+
self.nn2 = ProjectFactory(is_public=True, title='Noteworthy Bravo')
24+
self.nn3 = ProjectFactory(is_public=True, title='Noteworthy Charlie')
25+
self.nn4 = ProjectFactory(is_public=True, title='Noteworthy Foxtrot')
26+
self.nn5 = ProjectFactory(is_public=True, title='Noteworthy Golf')
2427

2528
self.all_ids = {self.nn1._id, self.nn2._id, self.nn3._id, self.nn4._id, self.nn5._id}
2629

@@ -32,6 +35,7 @@ def test_get_new_and_noteworthy_nodes(self):
3235
new_noteworthy = script.get_new_and_noteworthy_nodes(self.new_and_noteworthy_links_node)
3336
assert set(new_noteworthy) == self.all_ids
3437

38+
@mock.patch.object(script, 'NEW_AND_NOTEWORTHY_LINKS_NODE', TEST_NEW_AND_NOTEWORTHY_GUID)
3539
def test_populate_new_and_noteworthy(self):
3640
assert self.new_and_noteworthy_links_node._nodes.count() == 0
3741

tests/test_registrations/test_views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def test_node_register_page_not_registration_redirects(self):
5050
@mock.patch('website.archiver.tasks.archive')
5151
def test_node_register_page_registration(self, mock_archive):
5252
draft_reg = DraftRegistrationFactory(branched_from=self.node, user=self.node.creator)
53-
reg = self.node.register_node(get_default_metaschema(), self.auth, draft_reg, None)
53+
reg = self.node.register_node(get_default_metaschema(), self.auth, draft_reg, None, provider=draft_reg.provider)
5454
url = reg.web_url_for('node_register_page')
5555
res = self.app.get(url, auth=self.user.auth)
5656
assert res.status_code == http_status.HTTP_200_OK

0 commit comments

Comments
 (0)