-
Notifications
You must be signed in to change notification settings - Fork 359
[ENG-10309] Add meta to API preprint detail view to indicate spam status #11604
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
adlius
merged 19 commits into
CenterForOpenScience:feature/pbs-26-2
from
mkovalua:feature/ENG-10309
Mar 2, 2026
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
2a79e57
indicate if the preprint is spammy with meta: {flagged_content: true}
mkovalua abe9b0d
make sure that the sitemap doesn’t include any spammy preprint.
mkovalua d126271
update generate sitemap test
mkovalua a292245
get base get_meta in child meta to keep all needed meta data
mkovalua 2a77bfb
exclude spam content for preprints sitemap
mkovalua daba772
unify server response on getting specific registry/node/preprint if i…
mkovalua 4975521
exclude spam from Nodes and Registrations on sitemap generation
mkovalua 21f1f22
avoid errors for objects where spam may not be determined
mkovalua 0fbc41f
update code
mkovalua 41b19fd
show more specific message for spammy resource on contributor access …
mkovalua 08f174e
implement unittests for spammy resource contributor access
mkovalua e08cc31
refactor code
mkovalua cbdda32
show if resource is spammed on retrieval to all types of user
mkovalua 4b729a8
add tests
mkovalua 50985ca
ensure that the sitemap is working correctly for spammed content
mkovalua bee11d9
Delete api_tests/preprints/views/test_preprint_detail_new_behaviors.py
mkovalua a0246b2
raise Gone for deleted not spammed preprint to keep it same as for ot…
mkovalua c45e0d1
change 404 to 410 for deleted preprints in tests
mkovalua fc5f876
change 404 to 410 for deleted preprints in tests
mkovalua File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -179,6 +179,26 @@ def test_return_affiliated_institutions(self, app, user, preprint, institution, | |
| relationship_link = res.json['data']['relationships']['affiliated_institutions']['links']['self']['href'] | ||
| assert f'/v2/preprints/{preprint._id}/relationships/institutions/' in relationship_link | ||
|
|
||
| def test_spammed_preprint_detail_gone(self, app, preprint, user, url): | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And here |
||
| preprint.confirm_spam(save=True, train_spam_services=False) | ||
| url = f'/{API_BASE}preprints/{preprint._id}/' | ||
| res = app.get(url, expect_errors=True) | ||
| assert res.status_code == 410 | ||
| error = res.json['errors'][0] | ||
| assert error['detail'] == 'The requested preprint is no longer available.' | ||
| assert 'meta' in error | ||
| assert error['meta']['flagged_content'] is True | ||
|
|
||
| def test_not_spammed_deleted_preprint_detail_gone(self, app, preprint, user, url): | ||
| preprint.deleted = timezone.now() | ||
| preprint.save() | ||
| res = app.get(url, expect_errors=True) | ||
| assert res.status_code == 410 | ||
| error = res.json['errors'][0] | ||
| assert error['detail'] == 'The requested preprint is no longer available.' | ||
| assert 'meta' in error | ||
| assert not error['meta'].get('flagged_content', False) | ||
|
|
||
|
|
||
| @pytest.mark.django_db | ||
| class TestPreprintDelete: | ||
|
|
||
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -233,6 +233,29 @@ def test_registration_detail( | |
| expected_url = f'{public_url}relationships/subjects/' | ||
| assert urlparse(self_url).path == expected_url | ||
|
|
||
| def test_spammed_registration_detail_gone(self, app, user, public_registration, private_registration): | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And also here |
||
| for registration in (public_registration, private_registration): | ||
| registration.confirm_spam(save=True, train_spam_services=False) | ||
| url = f'/{API_BASE}registrations/{registration._id}/' | ||
| res = app.get(url, expect_errors=True) | ||
| assert res.status_code == 410 | ||
| error = res.json['errors'][0] | ||
| assert error['detail'] == 'The requested registration is no longer available.' | ||
| assert 'meta' in error | ||
| assert error['meta']['flagged_content'] | ||
|
|
||
| def test_not_spammed_detailed_registration_detail_gone(self, app, user, public_registration, private_registration): | ||
| for registration in (public_registration, private_registration): | ||
| registration.deleted = timezone.now() | ||
| registration.save() | ||
| url = f'/{API_BASE}registrations/{registration._id}/' | ||
| res = app.get(url, expect_errors=True) | ||
| assert res.status_code == 410 | ||
| error = res.json['errors'][0] | ||
| assert error['detail'] == 'The requested registration is no longer available.' | ||
| assert 'meta' in error | ||
| assert not error['meta'].get('flagged_content', False) | ||
|
|
||
|
|
||
| class TestRegistrationUpdateTestCase: | ||
|
|
||
|
|
||
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might want to check for the other case, where the non-spammed deleted file does not get the flagged content meta set to true.