Skip to content

Commit

Permalink
Removed Old Methods check permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
dyohan9 committed Oct 8, 2019
1 parent e9610d9 commit fbf26ce
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 23 deletions.
2 changes: 1 addition & 1 deletion bothub/api/v2/repository/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ class RepositoryUpload(serializers.Serializer):
class RepositoryGroupPermissionsSerializer(serializers.ModelSerializer):
class Meta:
model = UserGroupRepository
fields = ["uuid", "name", "permission"]
fields = ["uuid", "repository", "name", "permission"]
ref_name = None

permission = serializers.SerializerMethodField()
Expand Down
19 changes: 0 additions & 19 deletions bothub/common/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1067,25 +1067,6 @@ def check_permission(self, code_permission):
codename=PermissionsCode.objects.filter(codename=code_permission).first()
).exists()

#
# @property
# def can_contribute(self):
# return True
# # return self.level in [
# # RepositoryAuthorization.LEVEL_CONTRIBUTOR,
# # RepositoryAuthorization.LEVEL_ADMIN,
# # ]
#
# @property
# def can_write(self):
# return True
# # return self.level in [RepositoryAuthorization.LEVEL_ADMIN]
#
# @property
# def is_admin(self):
# return True
# # return self.level == RepositoryAuthorization.LEVEL_ADMIN

@property
def is_owner(self):
try:
Expand Down
6 changes: 3 additions & 3 deletions bothub/common/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,15 +328,15 @@ def test_can_read(self):
self.owner, return_group="Owner"
)
self.assertTrue(authorization_owner.check_permission("view.repository"))
# # secondary user in public repository
# secondary user in public repository
authorization_user = self.repository.get_user_authorization(self.user)
self.assertTrue(authorization_user.check_permission("view.repository"))
# # private repository owner
# private repository owner
private_authorization_owner = self.private_repository.get_user_authorization(
self.owner, return_group="Owner"
)
self.assertTrue(private_authorization_owner.check_permission("view.repository"))
# # secondary user in private repository
# secondary user in private repository
private_authorization_user = self.private_repository.get_user_authorization(
self.user
)
Expand Down

0 comments on commit fbf26ce

Please sign in to comment.