diff --git a/api/base/permissions.py b/api/base/permissions.py index 70663eba4f8..8b3c7247f7a 100644 --- a/api/base/permissions.py +++ b/api/base/permissions.py @@ -170,6 +170,6 @@ def has_object_permission(self, request, view, obj): resource = obj['self'] if request.method in permissions.SAFE_METHODS: - return resource.is_public or resource.has_permission(auth.user, 'read') or resource.can_view(auth) + return resource.is_public or resource.can_view(auth) else: return resource.can_edit(auth) diff --git a/api_tests/preprints/views/test_preprint_institutions_relationship.py b/api_tests/preprints/views/test_preprint_institutions_relationship.py index 62b64d2af9b..4186adb8ef3 100644 --- a/api_tests/preprints/views/test_preprint_institutions_relationship.py +++ b/api_tests/preprints/views/test_preprint_institutions_relationship.py @@ -1,6 +1,8 @@ import pytest from api.base.settings.defaults import API_BASE from osf_tests.factories import PreprintFactory, AuthUserFactory, InstitutionFactory +from osf.utils.permissions import READ, WRITE, ADMIN + @pytest.mark.django_db class TestPreprintInstitutionsRelationship: @@ -13,21 +15,21 @@ def user(self): @pytest.fixture() def admin_with_institutional_affiliation(self, institution, preprint): user = AuthUserFactory() - preprint.add_permission(user, 'admin') + preprint.add_contributor(user, permissions=ADMIN) user.add_or_update_affiliated_institution(institution) return user @pytest.fixture() def write_user_with_institutional_affiliation(self, institution, preprint): user = AuthUserFactory() - preprint.add_permission(user, 'write') + preprint.add_contributor(user, permissions=WRITE) user.add_or_update_affiliated_institution(institution) return user @pytest.fixture() def read_user_with_institutional_affiliation(self, institution, preprint): user = AuthUserFactory() - preprint.add_permission(user, 'read') + preprint.add_contributor(user, permissions=READ) user.add_or_update_affiliated_institution(institution) return user @@ -41,7 +43,7 @@ def no_auth_with_institutional_affiliation(self, institution): @pytest.fixture() def admin_without_institutional_affiliation(self, preprint): user = AuthUserFactory() - preprint.add_permission(user, 'admin') + preprint.add_contributor(user, permissions=ADMIN) return user @pytest.fixture()