# HG changeset patch # User Marcin Kuzminski # Date 2018-01-24 16:14:34 # Node ID 3250285e9544ee8b4c3353c15d41e4ddb7ace35c # Parent 4f07613493866fe8cf48eb13343beac8694fefd6 user-account: expose membership of user groups to users. - for review rules this might come in handy - it's not a secret information about which groups user belongs too diff --git a/rhodecode/apps/my_account/__init__.py b/rhodecode/apps/my_account/__init__.py --- a/rhodecode/apps/my_account/__init__.py +++ b/rhodecode/apps/my_account/__init__.py @@ -70,6 +70,11 @@ def includeme(config): name='my_account_ssh_keys_delete', pattern=ADMIN_PREFIX + '/my_account/ssh_keys/delete') + # my account user group membership + config.add_route( + name='my_account_user_group_membership', + pattern=ADMIN_PREFIX + '/my_account/user_group_membership') + # my account emails config.add_route( name='my_account_emails', diff --git a/rhodecode/apps/my_account/views/my_account.py b/rhodecode/apps/my_account/views/my_account.py --- a/rhodecode/apps/my_account/views/my_account.py +++ b/rhodecode/apps/my_account/views/my_account.py @@ -48,6 +48,7 @@ from rhodecode.model.pull_request import from rhodecode.model.scm import RepoList from rhodecode.model.user import UserModel from rhodecode.model.repo import RepoModel +from rhodecode.model.user_group import UserGroupModel from rhodecode.model.validation_schema.schemas import user_schema log = logging.getLogger(__name__) @@ -583,3 +584,16 @@ class MyAccountView(BaseAppView, DataGri data = self._get_pull_requests_list(statuses=statuses) return data + @LoginRequired() + @NotAnonymous() + @view_config( + route_name='my_account_user_group_membership', + request_method='GET', + renderer='rhodecode:templates/admin/my_account/my_account.mako') + def my_account_user_group_membership(self): + c = self.load_default_context() + c.active = 'user_group_membership' + groups = [UserGroupModel.get_user_groups_as_dict(group.users_group) + for group in self._rhodecode_db_user.group_member] + c.user_groups = json.dumps(groups) + return self._get_template_context(c) diff --git a/rhodecode/templates/admin/my_account/my_account.mako b/rhodecode/templates/admin/my_account/my_account.mako --- a/rhodecode/templates/admin/my_account/my_account.mako +++ b/rhodecode/templates/admin/my_account/my_account.mako @@ -30,6 +30,8 @@
  • ${_('Password')}
  • ${_('Auth Tokens')}
  • ${_('SSH Keys')}
  • +
  • ${_('User Group Membership')}
  • + ## TODO: Find a better integration of oauth views into navigation. <% my_account_oauth_url = h.route_path_or_none('my_account_oauth') %> % if my_account_oauth_url: diff --git a/rhodecode/templates/admin/my_account/my_account_user_group_membership.mako b/rhodecode/templates/admin/my_account/my_account_user_group_membership.mako new file mode 100644 --- /dev/null +++ b/rhodecode/templates/admin/my_account/my_account_user_group_membership.mako @@ -0,0 +1,75 @@ +## -*- coding: utf-8 -*- + +
    +
    +

    ${_('User Group Membership')}

    +
    + +
    +
    +
    +
    +
    +
    +
    +
    + + + \ No newline at end of file