diff --git a/api/preprints/serializers.py b/api/preprints/serializers.py index 6a00e581f4d7..5e74c162d2f8 100644 --- a/api/preprints/serializers.py +++ b/api/preprints/serializers.py @@ -144,6 +144,16 @@ class PreprintSerializer(TaxonomizableSerializerMixin, MetricsSerializerMixin, J related_view_kwargs={'preprint_id': '<_id>'}, )) + affiliated_institutions = RelationshipField( + related_view='preprints:preprints-institutions', + related_view_kwargs={'preprint_id': '<_id>'}, + self_view='preprints:preprints-institutions', + self_view_kwargs={'preprint_id': '<_id>'}, + read_only=False, + required=False, + allow_null=True, + ) + identifiers = NoneIfWithdrawal(RelationshipField( related_view='preprints:identifier-list', related_view_kwargs={'preprint_id': '<_id>'}, diff --git a/api_tests/preprints/views/test_preprint_list.py b/api_tests/preprints/views/test_preprint_list.py index 1935de0270a8..6128ff279dfa 100644 --- a/api_tests/preprints/views/test_preprint_list.py +++ b/api_tests/preprints/views/test_preprint_list.py @@ -67,5 +67,6 @@ def test_return_affiliated_institutions(self): assert_equal(len(res.json['data']), 1) assert_equal(res.status_code, 200) assert_equal(res.content_type, 'application/vnd.api+json') - relationship_link = res.json['data'][0]['relationships']['affiliated_institutions']['links']['href'] + print(res.json) + relationship_link = res.json['data'][0]['relationships']['affiliated_institutions']['links']['related']['href'] assert f'/v2/preprints/{self.preprint._id}/institutions/' in relationship_link diff --git a/api_tests/preprints/views/test_preprint_update.py b/api_tests/preprints/views/test_preprint_update.py index 2a841b62472f..879af500df46 100644 --- a/api_tests/preprints/views/test_preprint_update.py +++ b/api_tests/preprints/views/test_preprint_update.py @@ -61,29 +61,6 @@ def test_update_preprint_permission_denied(self, app, preprint, url): res = app.patch_json_api(url, update_doi_payload, auth=read_contrib.auth, expect_errors=True) assert res.status_code == 403 - def test_update_original_publication_date_to_none(self, app, preprint, url): - write_contrib = AuthUserFactory() - preprint.add_contributor(write_contrib, WRITE, save=True) - preprint.original_publication_date = '2013-12-11 10:09:08.070605+00:00' - preprint.save() - update_payload = build_preprint_update_payload(preprint._id, attributes={'original_publication_date': None}) - - res = app.patch_json_api(url, update_payload, auth=write_contrib.auth) - assert res.status_code == 200 - preprint.reload() - assert preprint.original_publication_date is None - - def test_update_custom_publication_citation_to_none(self, app, preprint, url): - write_contrib = AuthUserFactory() - preprint.add_contributor(write_contrib, WRITE, save=True) - preprint.custom_publication_citation = 'fake citation' - preprint.save() - update_payload = build_preprint_update_payload(preprint._id, attributes={'custom_publication_citation': None}) - res = app.patch_json_api(url, update_payload, auth=write_contrib.auth) - assert res.status_code == 200 - preprint.reload() - assert preprint.custom_publication_citation is None - @responses.activate @mock.patch('osf.models.preprint.update_or_enqueue_on_preprint_updated', mock.Mock()) def test_update_preprint_permission_write_contrib(self, app, preprint, url): @@ -264,14 +241,6 @@ def test_update_original_publication_date(self, app, user, preprint, url): preprint.reload() assert preprint.original_publication_date == date - def test_update_custom_publication_citation(self, app, user, preprint, url): - citation = 'fake citation' - update_payload = build_preprint_update_payload(preprint._id, attributes={'custom_publication_citation': citation}) - res = app.patch_json_api(url, update_payload, auth=user.auth) - assert res.status_code == 200 - preprint.reload() - assert preprint.custom_publication_citation == citation - @responses.activate @mock.patch('osf.models.preprint.update_or_enqueue_on_preprint_updated', mock.Mock()) def test_update_article_doi(self, app, user, preprint, url):