From 819a42b308db241f86015076db12e62ab011f220 Mon Sep 17 00:00:00 2001 From: Victor Salles Date: Thu, 21 Jul 2022 13:20:10 -0300 Subject: [PATCH] Remove ROLE_TRANSLATE from RepositoryAuthorization and OrganizationAuthorization - Update tests (1 test affected) --- bothub/common/models.py | 20 +------------------- bothub/common/tests.py | 9 --------- 2 files changed, 1 insertion(+), 28 deletions(-) diff --git a/bothub/common/models.py b/bothub/common/models.py index 05163b183..2c11ee560 100644 --- a/bothub/common/models.py +++ b/bothub/common/models.py @@ -147,20 +147,17 @@ class Meta: LEVEL_READER = 1 LEVEL_CONTRIBUTOR = 2 LEVEL_ADMIN = 3 - LEVEL_TRANSLATE = 4 ROLE_NOT_SETTED = 0 ROLE_USER = 1 ROLE_CONTRIBUTOR = 2 ROLE_ADMIN = 3 - ROLE_TRANSLATE = 4 ROLE_CHOICES = [ (ROLE_NOT_SETTED, _("not set")), (ROLE_USER, _("user")), (ROLE_CONTRIBUTOR, _("contributor")), (ROLE_ADMIN, _("admin")), - (ROLE_TRANSLATE, _("translate")), ] uuid = models.UUIDField( @@ -191,9 +188,6 @@ def level(self): if self.role == OrganizationAuthorization.ROLE_ADMIN: return OrganizationAuthorization.LEVEL_ADMIN - if self.role == OrganizationAuthorization.ROLE_TRANSLATE: - return OrganizationAuthorization.LEVEL_TRANSLATE - return OrganizationAuthorization.LEVEL_NOTHING # pragma: no cover @property @@ -202,7 +196,6 @@ def can_read(self): OrganizationAuthorization.LEVEL_READER, OrganizationAuthorization.LEVEL_CONTRIBUTOR, OrganizationAuthorization.LEVEL_ADMIN, - OrganizationAuthorization.LEVEL_TRANSLATE, ] @property @@ -221,7 +214,6 @@ def can_translate(self): return self.level in [ OrganizationAuthorization.LEVEL_CONTRIBUTOR, OrganizationAuthorization.LEVEL_ADMIN, - OrganizationAuthorization.LEVEL_TRANSLATE, ] @property @@ -912,9 +904,7 @@ def get_user_authorization(self, user): if self.owner.is_organization: org_auth = self.owner.organization.get_organization_authorization(user) - # Excluding ROLE_TRANSLATE as it does not correspond to the same role in the client app (connect). - # todo: update this conditional with corresponding role rule - if repo_auth.role < org_auth.role and org_auth.role < RepositoryAuthorization.ROLE_TRANSLATE: + if repo_auth.role < org_auth.role: repo_auth.role = org_auth.role repo_auth.save(update_fields=['role']) return repo_auth @@ -1984,20 +1974,17 @@ class Meta: LEVEL_READER = 1 LEVEL_CONTRIBUTOR = 2 LEVEL_ADMIN = 3 - LEVEL_TRANSLATE = 4 ROLE_NOT_SETTED = 0 ROLE_USER = 1 ROLE_CONTRIBUTOR = 2 ROLE_ADMIN = 3 - ROLE_TRANSLATE = 4 ROLE_CHOICES = [ (ROLE_NOT_SETTED, _("not set")), (ROLE_USER, _("user")), (ROLE_CONTRIBUTOR, _("contributor")), (ROLE_ADMIN, _("admin")), - (ROLE_TRANSLATE, _("translate")), ] uuid = models.UUIDField( @@ -2060,9 +2047,6 @@ def level(self): if role == RepositoryAuthorization.ROLE_ADMIN: return RepositoryAuthorization.LEVEL_ADMIN - if role == RepositoryAuthorization.ROLE_TRANSLATE: - return RepositoryAuthorization.LEVEL_TRANSLATE - return RepositoryAuthorization.LEVEL_NOTHING # pragma: no cover @property @@ -2071,7 +2055,6 @@ def can_read(self): RepositoryAuthorization.LEVEL_READER, RepositoryAuthorization.LEVEL_CONTRIBUTOR, RepositoryAuthorization.LEVEL_ADMIN, - RepositoryAuthorization.LEVEL_TRANSLATE, ] @property @@ -2090,7 +2073,6 @@ def can_translate(self): return self.level in [ RepositoryAuthorization.LEVEL_CONTRIBUTOR, RepositoryAuthorization.LEVEL_ADMIN, - RepositoryAuthorization.LEVEL_TRANSLATE, ] @property diff --git a/bothub/common/tests.py b/bothub/common/tests.py index a9bfe5059..596c9b3cb 100644 --- a/bothub/common/tests.py +++ b/bothub/common/tests.py @@ -726,15 +726,6 @@ def test_organization_auth_over_repository_auth(self): user_authorization = self.organization_repository.get_user_authorization(self.collaborator) self.assertEqual(user_authorization.role, collaborator_repository_auth.role) - # Verify that org auth with (role >= 4) will not update the repository's authorization - - # Set user's role to ROLE_TRANSLATE level at the Organization - collaborator_organization_auth.role = OrganizationAuthorization.ROLE_TRANSLATE - collaborator_organization_auth.save() - - user_authorization = self.organization_repository.get_user_authorization(self.collaborator) - self.assertEqual(user_authorization.role, collaborator_repository_auth.role) - class RepositoryVersionTrainingTestCase(TestCase): def setUp(self):