Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions api/providers/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
WhitelistedSHAREPreprintProvider,
)
from osf.models.action import RegistrationAction, CollectionSubmissionAction
from osf.models.spam import SpamStatus
from osf.registrations.utils import (
BulkRegistrationUpload,
InvalidHeadersError,
Expand Down Expand Up @@ -778,6 +779,9 @@ def get_default_queryset(self):

return Registration.objects.filter(
provider=provider,
deleted__isnull=True,
).exclude(
spam_status__in=[SpamStatus.FLAGGED, SpamStatus.SPAM],
).annotate(
revision_state=registration_annotations.REVISION_STATE,
**resource_annotations.make_open_practice_badge_annotations(),
Expand Down
6 changes: 5 additions & 1 deletion api/registrations/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from website.project import signals as project_signals

from osf.models import Registration, OSFUser, RegistrationProvider, OutcomeArtifact, CedarMetadataRecord
from osf.models.spam import SpamStatus
from osf.utils.permissions import WRITE_NODE
from osf.utils.workflows import ApprovalStates

Expand Down Expand Up @@ -922,7 +923,10 @@ def get_registration(self):
return registration

def get_default_queryset(self):
return self.get_registration().actions.all()
registration = self.get_registration()
if registration.deleted or registration.spam_status in [SpamStatus.FLAGGED, SpamStatus.SPAM]:
return registration.actions.none()
return registration.actions.all()

def get_queryset(self):
return self.get_queryset_from_request()
Expand Down
18 changes: 11 additions & 7 deletions scripts/tests/test_populate_new_and_noteworthy.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
from unittest import mock

from tests.base import OsfTestCase
from osf_tests.factories import ProjectFactory

from osf.models import Node
from website.settings import NEW_AND_NOTEWORTHY_LINKS_NODE

from scripts import populate_new_and_noteworthy_projects as script

TEST_NEW_AND_NOTEWORTHY_GUID = 'nguid'


class TestPopulateNewAndNoteworthy(OsfTestCase):

def setUp(self):
super().setUp()

self.new_and_noteworthy_links_node = ProjectFactory()
self.new_and_noteworthy_links_node._id = NEW_AND_NOTEWORTHY_LINKS_NODE
self.new_and_noteworthy_links_node._id = TEST_NEW_AND_NOTEWORTHY_GUID
self.new_and_noteworthy_links_node.save()

self.nn1 = ProjectFactory(is_public=True)
self.nn2 = ProjectFactory(is_public=True)
self.nn3 = ProjectFactory(is_public=True)
self.nn4 = ProjectFactory(is_public=True)
self.nn5 = ProjectFactory(is_public=True)
self.nn1 = ProjectFactory(is_public=True, title='Noteworthy Alpha')
self.nn2 = ProjectFactory(is_public=True, title='Noteworthy Bravo')
self.nn3 = ProjectFactory(is_public=True, title='Noteworthy Charlie')
self.nn4 = ProjectFactory(is_public=True, title='Noteworthy Foxtrot')
self.nn5 = ProjectFactory(is_public=True, title='Noteworthy Golf')

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

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

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

Expand Down
2 changes: 1 addition & 1 deletion tests/test_registrations/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def test_node_register_page_not_registration_redirects(self):
@mock.patch('website.archiver.tasks.archive')
def test_node_register_page_registration(self, mock_archive):
draft_reg = DraftRegistrationFactory(branched_from=self.node, user=self.node.creator)
reg = self.node.register_node(get_default_metaschema(), self.auth, draft_reg, None)
reg = self.node.register_node(get_default_metaschema(), self.auth, draft_reg, None, provider=draft_reg.provider)
url = reg.web_url_for('node_register_page')
res = self.app.get(url, auth=self.user.auth)
assert res.status_code == http_status.HTTP_200_OK
Expand Down
Loading