Skip to content
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

[ENG-6812] BE Reference PR for Preprints DOI Versioning #10816

Closed
wants to merge 272 commits into from
Closed
Changes from 3 commits
Commits
Show all changes
272 commits
Select commit Hold shift + click to select a range
f6974a9
removed breakpoint and added comment
Ostap-Zherebetskyi Nov 21, 2024
7d1499c
updated PreprintCreateVersionSerializer
Ostap-Zherebetskyi Nov 25, 2024
e11ce27
updated PreprintVersionsList inheritance
Ostap-Zherebetskyi Nov 25, 2024
2f61566
added PendingVersionExists error
Ostap-Zherebetskyi Nov 25, 2024
81f4083
added bypass for user.is_affiliated_with_institution
Ostap-Zherebetskyi Nov 25, 2024
acb0fa2
added has_create_version_permission method for Preprint
Ostap-Zherebetskyi Nov 25, 2024
eef1930
updated errors and renamed field
Ostap-Zherebetskyi Nov 26, 2024
7a2c17d
renamed dupliate_from_guid field to create_from_guid
Ostap-Zherebetskyi Nov 26, 2024
6eb89fd
renamed error
Ostap-Zherebetskyi Nov 26, 2024
320823d
update create_version method
Ostap-Zherebetskyi Nov 26, 2024
040d6d7
created method for saving DOI locally bypassing CrossRef
Nov 20, 2024
d6aa917
fixed comments
Nov 21, 2024
d9afea5
Fix preprints submission failure due to notification guid length
cslzchen Nov 22, 2024
adf8c15
updated build_posted_content to include doi_relations
Nov 22, 2024
f1e2d23
reformatted methods
Nov 25, 2024
ee22147
changed logic of relations
Nov 26, 2024
40c872b
using version instead of PK
Nov 26, 2024
ecfcfa3
Remove migration files osf_0023 and osf_0024
cslzchen Nov 28, 2024
effeb79
Tweak GuidVersionsThrough
cslzchen Nov 28, 2024
3fd8954
Redo migration
cslzchen Nov 28, 2024
d3ba3df
update router for versioned guid
Ostap-Zherebetskyi Nov 29, 2024
94f4a60
Fix failed tests after DOI updates
Vlad0n20 Nov 26, 2024
8e88024
Update factories
Vlad0n20 Nov 29, 2024
47a5695
Remove factories for Guid
Vlad0n20 Nov 29, 2024
957265b
unit tests for preprint version API
Ostap-Zherebetskyi Nov 28, 2024
12af1e9
update preprint license
Ostap-Zherebetskyi Nov 29, 2024
3a82e0d
updated get_preprint method in PreprintMixin
Ostap-Zherebetskyi Dec 2, 2024
4f0cf59
added propery is_last_version and created a method to check is prepri…
Nov 28, 2024
19b1992
intial refactor
Nov 29, 2024
3c88b94
implemented last version check
Dec 2, 2024
f667562
optimized version filtering
bodintsov Dec 2, 2024
3d11523
improve logic, naming
bodintsov Dec 3, 2024
face521
added PublishedPreprintManager for the Preprint
Ostap-Zherebetskyi Dec 3, 2024
562dc66
updated get_preprint method
Ostap-Zherebetskyi Dec 3, 2024
fda3ae4
versioned preprint update
Ostap-Zherebetskyi Dec 3, 2024
4a6baae
restore comment
Ostap-Zherebetskyi Dec 3, 2024
903cd65
Merge pull request #10818 from Ostap-Zherebetskyi/fix/GUID_routing
cslzchen Dec 3, 2024
3ad75fb
Merge pull request #10819 from Ostap-Zherebetskyi/feature/preprint_tests
cslzchen Dec 3, 2024
3fb7d62
Merge pull request #10815 from bodintsov/feature/implement_latest_ver…
cslzchen Dec 3, 2024
9b3dbb4
added reject preprint update mixin
Ostap-Zherebetskyi Dec 2, 2024
c797860
updated RejectPreprintEditMixin
Ostap-Zherebetskyi Dec 3, 2024
17ceaf0
updated RejectPreprintEditMixin
Ostap-Zherebetskyi Dec 5, 2024
9a7e0f7
Add tests for GuidVersionsThrough
Vlad0n20 Dec 5, 2024
333d7c1
Update tests for GuidVersionsThrough
Vlad0n20 Dec 5, 2024
998d01d
updated sitemap generator
bodintsov Dec 6, 2024
a12568e
removed current implementation check
bodintsov Dec 6, 2024
684eed0
removed imports
bodintsov Dec 6, 2024
9d9ad2b
rename RejectPreprintEditMixin to PreprintOldVersionsImmutableMixin
Ostap-Zherebetskyi Dec 6, 2024
54dcc5b
added versioned guid support
Ostap-Zherebetskyi Dec 6, 2024
e9a1918
Merge pull request #10820 from Ostap-Zherebetskyi/feature/reject_prep…
cslzchen Dec 6, 2024
608825d
updated ReviewableMixin for the versioned preprints
Ostap-Zherebetskyi Dec 5, 2024
4708caf
versioned preprints refactor
Ostap-Zherebetskyi Dec 6, 2024
e876fb0
Add new checks for version guid tests
Vlad0n20 Dec 9, 2024
b395aaa
versioned preprints refactor
Ostap-Zherebetskyi Dec 9, 2024
4a4605c
removed unused parameter
Ostap-Zherebetskyi Dec 9, 2024
b3fc503
update preprint load method
Ostap-Zherebetskyi Dec 9, 2024
7778524
updated split_guid method
Ostap-Zherebetskyi Dec 9, 2024
4a64cc1
Merge pull request #10828 from Ostap-Zherebetskyi/feature/rejected_pr…
cslzchen Dec 9, 2024
4a7aa35
Merge pull request #10813 from Vlad0n20/fix/ENG-6558
cslzchen Dec 9, 2024
c507291
Merge remote-tracking branch 'upstream/feature/preprints-doi-versioni…
Ostap-Zherebetskyi Dec 10, 2024
fec70d2
refactored code, removed useless
bodintsov Dec 10, 2024
b947839
removed litter
bodintsov Dec 10, 2024
a49ec3c
versioned preprints refactor
Ostap-Zherebetskyi Dec 10, 2024
46a4a2a
versioned preprints refactor
Ostap-Zherebetskyi Dec 10, 2024
6dc0b3c
Merge pull request #10834 from Ostap-Zherebetskyi/fix/refactor_versio…
cslzchen Dec 10, 2024
fc70e02
Merge pull request #10829 from bodintsov/feature/update_sitemap_gener…
cslzchen Dec 10, 2024
a0b891d
Fix most api_2 tests
Vlad0n20 Dec 6, 2024
ba86b08
Fix preprint admin tests. The issue was that in WithdrawalRequestMixi…
Vlad0n20 Dec 5, 2024
e350bd0
Update API for version guid and remove test fixes
Vlad0n20 Dec 10, 2024
a9c5d8d
Remove useless code
Vlad0n20 Dec 10, 2024
c9c85e1
Merge pull request #10830 from Vlad0n20/fix/ENG-6547
cslzchen Dec 10, 2024
d551677
fixed 500 eror on invalid guid
bodintsov Dec 11, 2024
56d2d4e
added tests for versioned DOI and crossref metadata
bodintsov Dec 11, 2024
0888f31
updated PreprintOldVersionsImmutableMixin
Ostap-Zherebetskyi Dec 12, 2024
80267ff
added unique constraint to GuidVersionsThrough
bodintsov Dec 12, 2024
7008790
Fix website tests
Vlad0n20 Dec 12, 2024
fcc61de
Merge pull request #10839 from bodintsov/feature/improve_version_inel…
cslzchen Dec 12, 2024
66aea3f
Merge pull request #10846 from Ostap-Zherebetskyi/fix/update_Preprint…
cslzchen Dec 12, 2024
c06e1eb
Merge pull request #10848 from bodintsov/feature/add_uniqueness_to_gu…
cslzchen Dec 12, 2024
70ca5eb
Simplify resolve guid
cslzchen Dec 12, 2024
9f2b980
Merge pull request #10850 from Vlad0n20/fix/ENG-6700
cslzchen Dec 12, 2024
6f362f5
Fix flake8: remove unused import
cslzchen Dec 13, 2024
c075143
added checks for preprint version, fixed tests
bodintsov Dec 13, 2024
7ac2544
Fix assert error in checkin_files_task for website tests
Vlad0n20 Dec 13, 2024
2396c7e
Merge pull request #10852 from Vlad0n20/fix/ENG-6727
cslzchen Dec 13, 2024
5a842c0
Refactor/Document preprint factory version creation
cslzchen Dec 13, 2024
93997e5
Merge pull request #10840 from bodintsov/feature/crossref_and_doi_tests
cslzchen Dec 14, 2024
5e1778e
Rework version creation for model and factory
cslzchen Dec 14, 2024
d7ad314
Fix preprint version creation in crossref tests
cslzchen Dec 16, 2024
a142a72
Fix imports
cslzchen Dec 16, 2024
1bee842
Merge pull request #10853 from cslzchen/feature/version-creation-rework
cslzchen Dec 16, 2024
2a54599
Fix api_3 test, without elasticsearch and share related
Vlad0n20 Dec 11, 2024
eb1f141
Update id_linked_preprints for versioned guids
Vlad0n20 Dec 13, 2024
2d70249
updated tests for sitemap generator
bodintsov Dec 17, 2024
90e6ce7
updated tests
bodintsov Dec 17, 2024
ef6a82e
Fix cressref tests
Vlad0n20 Dec 17, 2024
cc435b0
Merge pull request #10856 from bodintsov/feature/sitemap_generator_un…
cslzchen Dec 17, 2024
4b8894e
Merge pull request #10844 from Vlad0n20/fix/ENG-6673-api-3-test
cslzchen Dec 17, 2024
2706450
Merge remote-tracking branch 'upstream/develop' into feature/preprint…
cslzchen Dec 18, 2024
a9b1204
added sentry logs
bodintsov Dec 18, 2024
09814fd
Update FilterMixin for versioned guid
Vlad0n20 Dec 18, 2024
fa5059f
Add tests for PreprintFactory
Vlad0n20 Dec 16, 2024
1d02840
add tests for PreprintFactory.create_version method
Vlad0n20 Dec 17, 2024
3b86d10
fixed create versioned preprint
Ostap-Zherebetskyi Dec 18, 2024
e1a2630
Merge pull request #10855 from Vlad0n20/ENG-6701
cslzchen Dec 18, 2024
a71d0cf
Merge pull request #10863 from Ostap-Zherebetskyi/fix/versioned_prepr…
cslzchen Dec 18, 2024
7388f6f
refactored sentry messages
bodintsov Dec 19, 2024
2161f03
Add error handling for version guid in FilterMixin.parse_query_params…
Vlad0n20 Dec 19, 2024
a616115
updated file upload for the versioned preprint
Ostap-Zherebetskyi Dec 19, 2024
c8afa3f
Include only latest preprint version to project`s supplements
bodintsov Dec 19, 2024
c500fa5
fixed flake8 error
bodintsov Dec 20, 2024
f16431b
changed _id to base_guid._id according to SHARE update
Ostap-Zherebetskyi Dec 20, 2024
1264cdf
project supplements latest preprint API
bodintsov Dec 20, 2024
baa72c3
Merge pull request #10861 from bodintsov/feature/add_centry_logs_to_c…
cslzchen Dec 20, 2024
13de01d
Merge pull request #10864 from Ostap-Zherebetskyi/fix/versioned_prepr…
cslzchen Dec 20, 2024
8fddaf8
Merge pull request #10862 from Vlad0n20/fix/ENG-6646
cslzchen Dec 21, 2024
ba18d08
Merge pull request #10865 from bodintsov/feature/show_latest_preprint…
cslzchen Dec 21, 2024
7361352
Merge pull request #10868 from Ostap-Zherebetskyi/fix/SHARE_tests
cslzchen Dec 21, 2024
450e107
latest version of preprint in collections
bodintsov Dec 21, 2024
a1ab30d
Merge pull request #10870 from bodintsov/feature/collections_latests_…
cslzchen Dec 21, 2024
687249a
fixed preprint subjects [ENG-6791]
Ostap-Zherebetskyi Dec 24, 2024
45d7615
fixed tests, fixed issues
bodintsov Dec 24, 2024
5fee1e3
Merge pull request #10872 from Ostap-Zherebetskyi/fix/preprint_subjects
cslzchen Dec 26, 2024
4ad6cf3
Merge pull request #10873 from bodintsov/fix/fix_newly_broken_tests_d…
cslzchen Dec 26, 2024
46745ab
fixed preprint file download
Ostap-Zherebetskyi Dec 30, 2024
c2843f0
updated analytics task
Ostap-Zherebetskyi Dec 30, 2024
f9fc966
updated metrics
Ostap-Zherebetskyi Dec 31, 2024
26a2854
update metrics
Ostap-Zherebetskyi Dec 31, 2024
19b31bc
Merge pull request #10878 from Ostap-Zherebetskyi/feature/preprint_me…
cslzchen Dec 31, 2024
88e2f01
Add new tests for preprint moderation states
Vlad0n20 Dec 20, 2024
e2a3e4b
Add checks for new versions
Vlad0n20 Dec 23, 2024
5aa6ff9
Add new tests withdraw request for version preprints
Vlad0n20 Dec 27, 2024
32b8bba
Refactored preprint tests
cslzchen Dec 31, 2024
39b0f76
Merge pull request #10869 from Vlad0n20/ENG-6693
cslzchen Jan 1, 2025
05b9b2e
added Docstrings
Ostap-Zherebetskyi Dec 27, 2024
b331e48
More docstrings/comments for guid and versioned guid
cslzchen Jan 1, 2025
d7d6b18
Fix order for preprint api urls
cslzchen Jan 1, 2025
9fc83fa
More docstrings/comments
cslzchen Jan 1, 2025
d97e485
More docstrings/comments and code optimization
cslzchen Jan 1, 2025
fe83d4f
Merge pull request #10875 from Ostap-Zherebetskyi/feature/preprint_do…
cslzchen Jan 1, 2025
4f11af9
POC impln for handling orphaned version
cslzchen Dec 31, 2024
8d93f94
De-duplicate and normalize unfinished and unpublished check
cslzchen Dec 31, 2024
c3b8203
Merge unfinished and unpublished queries during version creation
cslzchen Dec 31, 2024
2d44a61
Update docstrings/comments + improve error handling
cslzchen Jan 1, 2025
40862ff
Remove duplicate and unuseful sentry logs
cslzchen Jan 1, 2025
ee7b187
Fix flake8
cslzchen Jan 1, 2025
b398764
Fix typo and add TODO
cslzchen Jan 1, 2025
f04e441
Elaborate more on the corner case where versioned guid doesn't exist
cslzchen Jan 1, 2025
c3f2abc
Improve preprint and version creation
cslzchen Jan 1, 2025
eb5b9c6
Merge pull request #10880 from cslzchen/feature/fix-orphaned-version
cslzchen Jan 2, 2025
b558511
added manage command for versioned preprints
Ostap-Zherebetskyi Jan 2, 2025
1c825c9
fixed flake8 issue
Ostap-Zherebetskyi Jan 2, 2025
cd5aa78
Add dry_run, tweak params, improve logs and handle null guid
cslzchen Jan 2, 2025
7282b68
Rename command name
cslzchen Jan 2, 2025
a3c2031
Remove unnecessary logs
cslzchen Jan 2, 2025
2a5e3a8
Merge pull request #10883 from Ostap-Zherebetskyi/feature/preprint_ma…
cslzchen Jan 2, 2025
495204f
Replace wrong exception handling with None check
cslzchen Jan 3, 2025
8ff49ba
Allow Guid.load() to ignore not found and don't log to sentry
cslzchen Jan 3, 2025
c5a602f
Merge pull request #10885 from cslzchen/feature/selenium-and-sentry-f…
cslzchen Jan 3, 2025
6a580d7
Fix CrossRef DOI check task
cslzchen Jan 3, 2025
24a19bb
Fix import
cslzchen Jan 3, 2025
0a46e0e
Improve/fix logs
cslzchen Jan 3, 2025
45af5db
Merge pull request #10886 from cslzchen/feature/fix-crossref-doi-check
cslzchen Jan 3, 2025
67904fb
Fix PreprintOldVersionsImmutableMixin
cslzchen Jan 3, 2025
8730deb
Fix api version to for subjects in preprint version api tests
cslzchen Jan 4, 2025
ffd65fd
Add and fix preprint version creation api tests
cslzchen Jan 4, 2025
11aca57
Fix flake8
cslzchen Jan 4, 2025
5f75be1
Merge pull request #10888 from cslzchen/feature/fix-preprint-mixin
cslzchen Jan 6, 2025
0c95c7d
Merge remote-tracking branch 'upstream/develop' into feature/preprint…
cslzchen Jan 6, 2025
a2bcee1
- ENG-6645 fix api1 failing tests in test_views.py
sh-andriy Dec 9, 2024
ab70669
- ENG-6645 fixed all failing tests api1
sh-andriy Dec 11, 2024
6591a47
- ENG-6645 fix failing tests api1
sh-andriy Dec 19, 2024
35657e3
- ENG-6645 fix failing tests api1
sh-andriy Dec 19, 2024
febabf3
- ENG-6645 fix test_create_preprint_with_supplementary_node + removed…
sh-andriy Dec 19, 2024
b478634
- ENG-6645 fix test_list + test_filter_actions
sh-andriy Dec 20, 2024
e2a79c2
- ENG-6645 code adjustments
sh-andriy Dec 24, 2024
0f3516b
- ENG-6645 pre-commit fix
sh-andriy Dec 26, 2024
ebdb887
Fix circular import for osf/models/mixins.py file
Vlad0n20 Dec 30, 2024
dc59d6a
Fix some comments to pull request
Vlad0n20 Jan 2, 2025
db2febe
Fix merge conflicts after rebase
Vlad0n20 Jan 2, 2025
bdb865f
Fix tests
Vlad0n20 Jan 3, 2025
593699f
Refactor api filters by id for prerpint
cslzchen Jan 6, 2025
17fdb76
Use Guid.split_guid() in test_create_preprint_with_supplementary_node
cslzchen Jan 6, 2025
33140fd
Revert incorret fix, which should not remove version info to pass
cslzchen Jan 6, 2025
d535d5e
Revoke incorrect fix: should fix `Preprint.save()` instead
cslzchen Jan 6, 2025
e1f2e80
Fix flake8
cslzchen Jan 6, 2025
6d4313b
Merge pull request #10879 from Vlad0n20/fix/ENG-6645
cslzchen Jan 7, 2025
503fbf0
Rework save() and update create() & create_version() for Prerpint
cslzchen Jan 7, 2025
235dca7
Update prerpint factories
cslzchen Jan 7, 2025
7e0d89e
Fix unit tests: must use factories or `.create()` to create preprint
cslzchen Jan 7, 2025
43243ab
Add missing kwargs when using `Preprint.create()` in some tests
cslzchen Jan 7, 2025
0164aec
Refactor _id property to use cached_property and fixed related tests
Ostap-Zherebetskyi Jan 6, 2025
317a5ab
update _id cache
Ostap-Zherebetskyi Jan 7, 2025
fb6b5f6
updated PreprintOldVersionsImmutableMixin checks
Ostap-Zherebetskyi Jan 6, 2025
62f2a98
allow resubmission for POST_MODERATION workflow
Ostap-Zherebetskyi Jan 6, 2025
ed31516
added comment
Ostap-Zherebetskyi Jan 7, 2025
116cba9
Improve PreprintOldVersionsImmutableMixin check
cslzchen Jan 7, 2025
f339355
Fix my preprints page; UserPreprints now returns only latest versions
Vlad0n20 Jan 7, 2025
cb168ca
Renam and improve _CachedTruthyProperty
cslzchen Jan 7, 2025
c6659c9
Use @cached_property as is; make version cached too
cslzchen Jan 7, 2025
c0e3af1
Futher improve preprint save
cslzchen Jan 7, 2025
7b16120
Merge pull request #10892 from cslzchen/feature/rework-prerpint-save
cslzchen Jan 7, 2025
79c911e
Merge remote-tracking branch 'upstream/develop' into feature/preprint…
cslzchen Jan 8, 2025
fdbc72c
fixed test TestPublicItemUsageReporter::test_reporter
Ostap-Zherebetskyi Jan 7, 2025
ff69865
fixed test TestGuidVersionsThrough::test_creation_versioned_guid
Ostap-Zherebetskyi Jan 7, 2025
948ad54
Fixed api3 unit tests
Ostap-Zherebetskyi Jan 8, 2025
f5c8aeb
fixed test_bad_requests according to the reviews update [ENG-6802]
Ostap-Zherebetskyi Jan 8, 2025
aed8dc0
fixed api3 unit tests
Ostap-Zherebetskyi Jan 8, 2025
0a93590
Fix contributor add when creating new versions
cslzchen Jan 8, 2025
00d2af1
Replace try with none check since .load() doesn't raise
cslzchen Jan 9, 2025
418245b
Fix format
cslzchen Jan 9, 2025
c818d8c
Merge pull request #10899 from cslzchen/feature/fix-contributor-add
cslzchen Jan 9, 2025
2f3e993
Merge pull request #10894 from Ostap-Zherebetskyi/fix/api3_unit_tests
cslzchen Jan 9, 2025
f415036
Refactor PreprintOldVersionsImmutableMixin and run_accept method
Ostap-Zherebetskyi Jan 9, 2025
be067dc
Minor format/style improvement
cslzchen Jan 9, 2025
608cce3
Merge pull request #10901 from Ostap-Zherebetskyi/fix/edit_rejected_p…
cslzchen Jan 9, 2025
8cce387
Code clean up
cslzchen Jan 9, 2025
a61659f
Add a TODO comment to fix broken filters
cslzchen Jan 9, 2025
d587741
Fix typo and update comment
cslzchen Jan 9, 2025
989ffd5
Merge pull request #10900 from cslzchen/feature/be-code-clean-up
cslzchen Jan 9, 2025
16574e2
Revert incorrect api filter fix for prerpint
cslzchen Jan 9, 2025
51c728e
Fix preprint edit permission
cslzchen Jan 9, 2025
2a8df88
Fix preprint contributor
cslzchen Jan 9, 2025
1aa3169
Implement preprint-action-list filtering on versioned _id
cslzchen Jan 10, 2025
73dc626
Implement review-action-list filtering on versioned _id
cslzchen Jan 10, 2025
96ca301
Fix tests where pending submit is allowed for post-moderation
cslzchen Jan 10, 2025
bc6ceae
Merge pull request #10906 from cslzchen/feature/fix-perm-and-contrib
cslzchen Jan 10, 2025
a5b4e05
Merge pull request #10905 from cslzchen/feature/fix-api-filters
cslzchen Jan 10, 2025
35d70c8
updated preprint filters
Ostap-Zherebetskyi Jan 10, 2025
4182a15
revert commit 45d7615 changes
Ostap-Zherebetskyi Jan 10, 2025
8bc1b00
Merge pull request #10907 from Ostap-Zherebetskyi/fix/preprint_filters
cslzchen Jan 10, 2025
3feb1d2
Fix ClaimUser view to support versioned preprint
cslzchen Jan 10, 2025
78c1522
Implement `PreprintProviderWithdrawRequestFilterMixin`,
cslzchen Jan 10, 2025
5eb448c
Merge pull request #10909 from cslzchen/feature/fix-claim-user-api
cslzchen Jan 10, 2025
d60dffd
Refactor versioned target filter mixin
cslzchen Jan 10, 2025
544d253
Fix migration command to include last preprint in batch processing
Ostap-Zherebetskyi Jan 13, 2025
b82d5ef
Merge pull request #10910 from cslzchen/feature/improve-versioned-id-…
cslzchen Jan 13, 2025
82be578
Add None check for guid_str at the very beginning
cslzchen Jan 13, 2025
e49b64c
Merge pull request #10912 from cslzchen/feature/improve-guid-none-check
cslzchen Jan 13, 2025
5dd6b36
updated total_migrated counter
Ostap-Zherebetskyi Jan 14, 2025
24c0399
updated digest notification template
Ostap-Zherebetskyi Jan 14, 2025
98e9236
Fix command log
cslzchen Jan 14, 2025
e860b30
Fix and improve query
cslzchen Jan 14, 2025
87b3059
Merge pull request #10918 from Ostap-Zherebetskyi/website_notifications
cslzchen Jan 14, 2025
8f71b73
Merge pull request #10911 from Ostap-Zherebetskyi/fix/preprint_manage…
cslzchen Jan 14, 2025
d08b031
Do not update share during version creation
cslzchen Jan 13, 2025
17cac23
Skip SHARE only but still update legacy OSF search
cslzchen Jan 14, 2025
1838633
Fix update_search for subclasses of VersionedGuidMixin
cslzchen Jan 14, 2025
b80855b
Fix set_subjects
cslzchen Jan 14, 2025
2d8c54e
Merge pull request #10917 from cslzchen/feature/fix-update-search-for…
cslzchen Jan 14, 2025
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: 2 additions & 2 deletions api/actions/views.py
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
from api.actions.permissions import ReviewActionPermission
from api.actions.serializers import NodeRequestActionSerializer, ReviewActionSerializer, PreprintRequestActionSerializer
from api.base.exceptions import Conflict
from api.base.filters import ReviewActionFilterMixin
from api.base.filters import TargetFilterMixin
from api.base.views import JSONAPIBaseView
from api.base.parsers import (
JSONAPIMultipleRelationshipsParser,
@@ -110,7 +110,7 @@ def get_object(self):
return action


class ReviewActionListCreate(JSONAPIBaseView, generics.ListCreateAPIView, ReviewActionFilterMixin):
class ReviewActionListCreate(JSONAPIBaseView, generics.ListCreateAPIView, TargetFilterMixin):
"""List of review actions viewable by this user

Actions represent state changes and/or comments on a reviewable object (e.g. a preprint)
53 changes: 29 additions & 24 deletions api/base/filters.py
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@
from osf.models import Subject, Preprint
from osf.models.base import GuidMixin, Guid
from functools import cmp_to_key
from framework import sentry

def lowercase(lower):
if hasattr(lower, '__call__'):
@@ -614,52 +615,56 @@ def preprints_queryset(self, base_queryset, auth_user, allow_contribs=True, publ
return preprints


class PreprintActionFilterMixin(ListFilterMixin):
"""View mixin for `PreprintActionList`. It inherits from `ListFilterMixin` and customize postprocessing for
versioned preprint.
class TargetFilterMixin(ListFilterMixin):
"""View mixin for multi-content-type list views (e.g. `ReviewActionListCreate`). It inherits from `ListFilterMixin`
and customizes the postprocessing of the `target` field when target is a preprint.

Note: Subclasses must define `get_default_queryset()`.
"""

@staticmethod
def postprocess_versioned_guid_target_query_param(operation):
"""When target is a preprint, which must be versioned, the traditional non-versioned `guid___id==target`
look-up no longer works. Must convert to PK look-up `referent__id==pk`.
def postprocess_preprint_as_target_query_param(operation, target_pk):
"""When target is a preprint, which must be versioned, the traditional non-versioned `guid___id==_id`
look-up no longer works. Must convert it to PK look-up `target__id==pk`.
"""
referent, version = Guid.load_referent(operation['value'])
# A valid preprint must have referent and version
if not referent or not version:
return
# Override the operation to filter `target__id=target.pk`
# Override the operation to filter `target__id==pk`
operation['source_field_name'] = 'target__id'
operation['value'] = referent.id
operation['value'] = target_pk
operation['op'] = 'eq'

def postprocess_query_param(self, key, field_name, operation):
"""Handles a special case when filtering on `target`.
"""Handles a special case when filtering on `target` when `target` is a Preprint.
"""
if field_name == 'target':
PreprintActionFilterMixin.postprocess_versioned_guid_target_query_param(operation)
referent, version = Guid.load_referent(operation['value'])
if referent:
if version:
TargetFilterMixin.postprocess_preprint_as_target_query_param(operation, referent.id)
else:
super().postprocess_query_param(key, field_name, operation)
else:
sentry.log_message(f'Target object invalid or not found: [target={operation['value']}]')
return
else:
super().postprocess_query_param(key, field_name, operation)

class ReviewActionFilterMixin(ListFilterMixin):
"""View mixin for `ReviewActionListCreate`. It inherits from `ListFilterMixin` and uses `PreprintActionFilterMixin`
to customized postprocessing for handling versioned preprint.

class PreprintAsTargetFilterMixin(TargetFilterMixin):
"""View mixin for preprint related list views (e.g. `PreprintProviderWithdrawRequestList` and `PreprintActionList`).
It inherits from `TargetFilterMixin` and customizes postprocessing the `target` field for preprint.

Note: Subclasses must define `get_default_queryset()`.
"""

def postprocess_query_param(self, key, field_name, operation):
"""Handles a special case when filtering on `target` and when `target` is a versioned Preprint.
"""Handles a special case when filtering on `target`.
"""
if field_name == 'target':
referent, version = Guid.load_referent(operation['value'])
if referent:
if version:
PreprintActionFilterMixin.postprocess_versioned_guid_target_query_param(operation)
else:
super().postprocess_query_param(key, field_name, operation)
else:
# A valid preprint must have referent and version
if not referent or not version:
sentry.log_message(f'Preprint invalid or note found: [target={operation['value']}]')
return
TargetFilterMixin.postprocess_preprint_as_target_query_param(operation, referent.id)
else:
super().postprocess_query_param(key, field_name, operation)
4 changes: 2 additions & 2 deletions api/preprints/views.py
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@
from api.base.pagination import PreprintContributorPagination
from api.base.exceptions import Conflict
from api.base.views import JSONAPIBaseView, WaterButlerMixin
from api.base.filters import ListFilterMixin, PreprintFilterMixin, PreprintActionFilterMixin
from api.base.filters import ListFilterMixin, PreprintAsTargetFilterMixin, PreprintFilterMixin
from api.base.parsers import (
JSONAPIMultipleRelationshipsParser,
JSONAPIMultipleRelationshipsParserForRegularJSON,
@@ -590,7 +590,7 @@ def get_object(self):
return obj


class PreprintActionList(JSONAPIBaseView, generics.ListCreateAPIView, PreprintActionFilterMixin, PreprintMixin):
class PreprintActionList(JSONAPIBaseView, generics.ListCreateAPIView, PreprintAsTargetFilterMixin, PreprintMixin):
"""Action List *Read-only*

Actions represent state changes and/or comments on a reviewable object (e.g. a preprint)
4 changes: 2 additions & 2 deletions api/providers/views.py
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@
InvalidFilterOperator,
InvalidFilterValue,
)
from api.base.filters import PreprintFilterMixin, ListFilterMixin
from api.base.filters import ListFilterMixin, PreprintAsTargetFilterMixin, PreprintFilterMixin
from api.base.metrics import PreprintMetricsViewMixin
from api.base.pagination import MaxSizePagination, IncreasedPageSizePagination
from api.base.settings import BULK_SETTINGS
@@ -571,7 +571,7 @@ def perform_create(self, serializer):
raise ValidationError(f'Provider {provider.name} has no primary collection to submit to.')


class PreprintProviderWithdrawRequestList(JSONAPIBaseView, generics.ListAPIView, ListFilterMixin, ProviderMixin):
class PreprintProviderWithdrawRequestList(JSONAPIBaseView, generics.ListAPIView, PreprintAsTargetFilterMixin, ProviderMixin):
provider_class = PreprintProvider
permission_classes = (
drf_permissions.IsAuthenticated,