Skip to content

Commit

Permalink
fix testing issues and clean-up permissions changes
Browse files Browse the repository at this point in the history
  • Loading branch information
John Tordoff committed Jul 29, 2024
1 parent 7362ce5 commit 9a272e4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion api/base/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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

Expand All @@ -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()
Expand Down

0 comments on commit 9a272e4

Please sign in to comment.