# HG changeset patch # User Marcin Kuzminski # Date 2012-11-06 22:26:42 # Node ID 4150c45b5f7fec75c800083da0ee36113a5e446e # Parent f8d827686e9ab4d83e94a4f6b790d250d74a42c3 Implemented #638 permissions overview to groups diff --git a/rhodecode/controllers/admin/users_groups.py b/rhodecode/controllers/admin/users_groups.py --- a/rhodecode/controllers/admin/users_groups.py +++ b/rhodecode/controllers/admin/users_groups.py @@ -40,10 +40,12 @@ from rhodecode.lib.base import BaseContr from rhodecode.model.users_group import UsersGroupModel -from rhodecode.model.db import User, UsersGroup +from rhodecode.model.db import User, UsersGroup, UsersGroupToPerm,\ + UsersGroupRepoToPerm, UsersGroupRepoGroupToPerm from rhodecode.model.forms import UsersGroupForm from rhodecode.model.meta import Session from rhodecode.lib.utils import action_logger +from sqlalchemy.orm import joinedload log = logging.getLogger(__name__) @@ -102,6 +104,38 @@ class UsersGroupsController(BaseControll # url('new_users_group') return render('admin/users_groups/users_group_add.html') + def _load_data(self, id): + c.users_group.permissions = { + 'repositories': {}, + 'repositories_groups': {} + } + + ugroup_repo_perms = UsersGroupRepoToPerm.query()\ + .options(joinedload(UsersGroupRepoToPerm.permission))\ + .options(joinedload(UsersGroupRepoToPerm.repository))\ + .filter(UsersGroupRepoToPerm.users_group_id == id)\ + .all() + + for gr in ugroup_repo_perms: + c.users_group.permissions['repositories'][gr.repository.repo_name] \ + = gr.permission.permission_name + + ugroup_group_perms = UsersGroupRepoGroupToPerm.query()\ + .options(joinedload(UsersGroupRepoGroupToPerm.permission))\ + .options(joinedload(UsersGroupRepoGroupToPerm.group))\ + .filter(UsersGroupRepoGroupToPerm.users_group_id == id)\ + .all() + + for gr in ugroup_group_perms: + c.users_group.permissions['repositories_groups'][gr.group.group_name] \ + = gr.permission.permission_name + + c.group_members_obj = [x.user for x in c.users_group.members] + c.group_members = [(x.user_id, x.username) for x in + c.group_members_obj] + c.available_members = [(x.user_id, x.username) for x in + User.query().all()] + def update(self, id): """PUT /users_groups/id: Update an existing item""" # Forms posted to this method should contain a hidden field: @@ -111,13 +145,8 @@ class UsersGroupsController(BaseControll # method='put') # url('users_group', id=ID) - c.users_group = UsersGroup.get(id) - c.group_members_obj = [x.user for x in c.users_group.members] - c.group_members = [(x.user_id, x.username) for x in - c.group_members_obj] - - c.available_members = [(x.user_id, x.username) for x in - User.query().all()] + c.users_group = UsersGroup.get_or_404(id) + self._load_data(id) available_members = [safe_unicode(x[0]) for x in c.available_members] @@ -189,13 +218,8 @@ class UsersGroupsController(BaseControll # url('edit_users_group', id=ID) c.users_group = UsersGroup.get_or_404(id) + self._load_data(id) - c.users_group.permissions = {} - c.group_members_obj = [x.user for x in c.users_group.members] - c.group_members = [(x.user_id, x.username) for x in - c.group_members_obj] - c.available_members = [(x.user_id, x.username) for x in - User.query().all()] ug_model = UsersGroupModel() defaults = c.users_group.get_dict() defaults.update({ diff --git a/rhodecode/public/css/style.css b/rhodecode/public/css/style.css --- a/rhodecode/public/css/style.css +++ b/rhodecode/public/css/style.css @@ -3935,12 +3935,13 @@ div#legend_container table td,div#legend .group_members_wrap{ - + min-height: 85px; + padding-left: 20px; } .group_members .group_member{ height: 30px; - padding:0px 0px 0px 10px; + padding:0px 0px 0px 0px; } .reviewers_member{ diff --git a/rhodecode/templates/admin/users_groups/users_group_edit.html b/rhodecode/templates/admin/users_groups/users_group_edit.html --- a/rhodecode/templates/admin/users_groups/users_group_edit.html +++ b/rhodecode/templates/admin/users_groups/users_group_edit.html @@ -145,20 +145,83 @@
${_('Group members')}
+
+ % if c.group_members_obj: + %else: + ${_('No members yet')} + %endif
+ +
+ +
+
${_('Permissions defined for this group')}
+
+ ## permissions overview +
+ %for section in sorted(c.users_group.permissions.keys()): +
${section.replace("_"," ").capitalize()}
+ %if not c.users_group.permissions: + ${_('No permissions set yet')} + %else: +
+ + + + + + + + + %for k in c.users_group.permissions[section]: + <% + section_perm = c.users_group.permissions[section].get(k) + _perm = section_perm.split('.')[-1] + %> + + + + + + %endfor + +
${_('Name')}${_('Permission')}${_('Edit Permission')}
+ %if section == 'repositories': + ${k} + %elif section == 'repositories_groups': + ${k} + %endif + + ${section_perm} + + %if section == 'repositories': + ${_('edit')} + %elif section == 'repositories_groups': + ${_('edit')} + %else: + -- + %endif +
+
+ %endif + %endfor +
+
+ +