##// END OF EJS Templates
auth: use pesistent naming of keys in auth. Refactoring only.
marcink -
r2064:4ebc0a2c default
parent child Browse files
Show More
@@ -617,11 +617,11 b' class PermissionCalculator(object):'
617 multiple_counter = collections.defaultdict(int)
617 multiple_counter = collections.defaultdict(int)
618 for perm in user_repo_perms_from_user_group:
618 for perm in user_repo_perms_from_user_group:
619 r_k = perm.UserGroupRepoToPerm.repository.repo_name
619 r_k = perm.UserGroupRepoToPerm.repository.repo_name
620 ug_k = perm.UserGroupRepoToPerm.users_group.users_group_name
621 multiple_counter[r_k] += 1
620 multiple_counter[r_k] += 1
621 p = perm.Permission.permission_name
622 o = PermOrigin.REPO_USERGROUP % perm.UserGroupRepoToPerm\
623 .users_group.users_group_name
622
624
623 p = perm.Permission.permission_name
624 o = PermOrigin.REPO_USERGROUP % ug_k
625 if multiple_counter[r_k] > 1:
625 if multiple_counter[r_k] > 1:
626 cur_perm = self.permissions_repositories[r_k]
626 cur_perm = self.permissions_repositories[r_k]
627 p = self._choose_permission(p, cur_perm)
627 p = self._choose_permission(p, cur_perm)
@@ -671,30 +671,30 b' class PermissionCalculator(object):'
671
671
672 multiple_counter = collections.defaultdict(int)
672 multiple_counter = collections.defaultdict(int)
673 for perm in user_repo_group_perms_from_user_group:
673 for perm in user_repo_group_perms_from_user_group:
674 g_k = perm.UserGroupRepoGroupToPerm.group.group_name
674 rg_k = perm.UserGroupRepoGroupToPerm.group.group_name
675 ug_k = perm.UserGroupRepoGroupToPerm.users_group.users_group_name
675 multiple_counter[rg_k] += 1
676 multiple_counter[g_k] += 1
676 o = PermOrigin.REPOGROUP_USERGROUP % perm.UserGroupRepoGroupToPerm\
677 o = PermOrigin.REPOGROUP_USERGROUP % ug_k
677 .users_group.users_group_name
678 p = perm.Permission.permission_name
678 p = perm.Permission.permission_name
679
679
680 if multiple_counter[g_k] > 1:
680 if multiple_counter[rg_k] > 1:
681 cur_perm = self.permissions_repository_groups[g_k]
681 cur_perm = self.permissions_repository_groups[rg_k]
682 p = self._choose_permission(p, cur_perm)
682 p = self._choose_permission(p, cur_perm)
683 self.permissions_repository_groups[g_k] = p, o
683 self.permissions_repository_groups[rg_k] = p, o
684
684
685 if perm.RepoGroup.user_id == self.user_id:
685 if perm.RepoGroup.user_id == self.user_id:
686 # set admin if owner, even for member of other user group
686 # set admin if owner, even for member of other user group
687 p = 'group.admin'
687 p = 'group.admin'
688 o = PermOrigin.REPOGROUP_OWNER
688 o = PermOrigin.REPOGROUP_OWNER
689 self.permissions_repository_groups[g_k] = p, o
689 self.permissions_repository_groups[rg_k] = p, o
690
690
691 # user explicit permissions for repository groups
691 # user explicit permissions for repository groups
692 user_repo_groups_perms = Permission.get_default_group_perms(
692 user_repo_groups_perms = Permission.get_default_group_perms(
693 self.user_id, self.scope_repo_group_id)
693 self.user_id, self.scope_repo_group_id)
694 for perm in user_repo_groups_perms:
694 for perm in user_repo_groups_perms:
695 rg_k = perm.UserRepoGroupToPerm.group.group_name
695 rg_k = perm.UserRepoGroupToPerm.group.group_name
696 u_k = perm.UserRepoGroupToPerm.user.username
696 o = PermOrigin.REPOGROUP_USER % perm.UserRepoGroupToPerm\
697 o = PermOrigin.REPOGROUP_USER % u_k
697 .user.username
698 p = perm.Permission.permission_name
698 p = perm.Permission.permission_name
699
699
700 if not self.explicit:
700 if not self.explicit:
@@ -721,33 +721,32 b' class PermissionCalculator(object):'
721
721
722 multiple_counter = collections.defaultdict(int)
722 multiple_counter = collections.defaultdict(int)
723 for perm in user_group_from_user_group:
723 for perm in user_group_from_user_group:
724 g_k = perm.UserGroupUserGroupToPerm\
724 ug_k = perm.UserGroupUserGroupToPerm\
725 .target_user_group.users_group_name
725 .target_user_group.users_group_name
726 u_k = perm.UserGroupUserGroupToPerm\
726 multiple_counter[ug_k] += 1
727 o = PermOrigin.USERGROUP_USERGROUP % perm.UserGroupUserGroupToPerm\
727 .user_group.users_group_name
728 .user_group.users_group_name
728 multiple_counter[g_k] += 1
729 o = PermOrigin.USERGROUP_USERGROUP % u_k
730 p = perm.Permission.permission_name
729 p = perm.Permission.permission_name
731
730
732 if multiple_counter[g_k] > 1:
731 if multiple_counter[ug_k] > 1:
733 cur_perm = self.permissions_user_groups[g_k]
732 cur_perm = self.permissions_user_groups[ug_k]
734 p = self._choose_permission(p, cur_perm)
733 p = self._choose_permission(p, cur_perm)
735
734
736 self.permissions_user_groups[g_k] = p, o
735 self.permissions_user_groups[ug_k] = p, o
737
736
738 if perm.UserGroup.user_id == self.user_id:
737 if perm.UserGroup.user_id == self.user_id:
739 # set admin if owner, even for member of other user group
738 # set admin if owner, even for member of other user group
740 p = 'usergroup.admin'
739 p = 'usergroup.admin'
741 o = PermOrigin.USERGROUP_OWNER
740 o = PermOrigin.USERGROUP_OWNER
742 self.permissions_user_groups[g_k] = p, o
741 self.permissions_user_groups[ug_k] = p, o
743
742
744 # user explicit permission for user groups
743 # user explicit permission for user groups
745 user_user_groups_perms = Permission.get_default_user_group_perms(
744 user_user_groups_perms = Permission.get_default_user_group_perms(
746 self.user_id, self.scope_user_group_id)
745 self.user_id, self.scope_user_group_id)
747 for perm in user_user_groups_perms:
746 for perm in user_user_groups_perms:
748 ug_k = perm.UserUserGroupToPerm.user_group.users_group_name
747 ug_k = perm.UserUserGroupToPerm.user_group.users_group_name
749 u_k = perm.UserUserGroupToPerm.user.username
748 o = PermOrigin.USERGROUP_USER % perm.UserUserGroupToPerm\
750 o = PermOrigin.USERGROUP_USER % u_k
749 .user.username
751 p = perm.Permission.permission_name
750 p = perm.Permission.permission_name
752
751
753 if not self.explicit:
752 if not self.explicit:
General Comments 0
You need to be logged in to leave comments. Login now