# HG changeset patch # User Marcin Kuzminski # Date 2012-07-01 22:22:57 # Node ID 19de74e33fb0e4aa9e8306436d85d1af712b89b4 # Parent d80a68e2ebcc0ca92d9de74e7d38ef83f4e7595e Better descriptions of given permission overview in edit user view diff --git a/rhodecode/lib/db_manage.py b/rhodecode/lib/db_manage.py --- a/rhodecode/lib/db_manage.py +++ b/rhodecode/lib/db_manage.py @@ -479,33 +479,12 @@ class DbManage(object): def create_permissions(self): # module.(access|create|change|delete)_[name] # module.(none|read|write|admin) - perms = [ - ('repository.none', 'Repository no access'), - ('repository.read', 'Repository read access'), - ('repository.write', 'Repository write access'), - ('repository.admin', 'Repository admin access'), - ('group.none', 'Repositories Group no access'), - ('group.read', 'Repositories Group read access'), - ('group.write', 'Repositories Group write access'), - ('group.admin', 'Repositories Group admin access'), - - ('hg.admin', 'Hg Administrator'), - ('hg.create.repository', 'Repository create'), - ('hg.create.none', 'Repository creation disabled'), - ('hg.register.none', 'Register disabled'), - ('hg.register.manual_activate', 'Register new user with RhodeCode ' - 'without manual activation'), - - ('hg.register.auto_activate', 'Register new user with RhodeCode ' - 'without auto activation'), - ] - - for p in perms: + for p in Permission.PERMS: if not Permission.get_by_key(p[0]): new_perm = Permission() new_perm.permission_name = p[0] - new_perm.permission_longname = p[1] + new_perm.permission_longname = p[0] self.sa.add(new_perm) def populate_default_permissions(self): diff --git a/rhodecode/lib/helpers.py b/rhodecode/lib/helpers.py --- a/rhodecode/lib/helpers.py +++ b/rhodecode/lib/helpers.py @@ -46,7 +46,7 @@ from rhodecode.lib.vcs.exceptions import from rhodecode.lib.vcs.backends.base import BaseChangeset from rhodecode.config.conf import DATE_FORMAT, DATETIME_FORMAT from rhodecode.model.changeset_status import ChangesetStatusModel -from rhodecode.model.db import URL_SEP +from rhodecode.model.db import URL_SEP, Permission log = logging.getLogger(__name__) @@ -1007,3 +1007,7 @@ def changeset_status(repo, revision): def changeset_status_lbl(changeset_status): return dict(ChangesetStatus.STATUSES).get(changeset_status) + + +def get_permission_name(key): + return dict(Permission.PERMS).get(key) diff --git a/rhodecode/model/db.py b/rhodecode/model/db.py --- a/rhodecode/model/db.py +++ b/rhodecode/model/db.py @@ -1058,6 +1058,28 @@ class Permission(Base, BaseModel): {'extend_existing': True, 'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'}, ) + PERMS = [ + ('repository.none', _('Repository no access')), + ('repository.read', _('Repository read access')), + ('repository.write', _('Repository write access')), + ('repository.admin', _('Repository admin access')), + + ('group.none', _('Repositories Group no access')), + ('group.read', _('Repositories Group read access')), + ('group.write', _('Repositories Group write access')), + ('group.admin', _('Repositories Group admin access')), + + ('hg.admin', _('RhodeCode Administrator')), + ('hg.create.none', _('Repository creation disabled')), + ('hg.create.repository', _('Repository creation enabled')), + ('hg.register.none', _('Register disabled')), + ('hg.register.manual_activate', _('Register new user with RhodeCode ' + 'with manual activation')), + + ('hg.register.auto_activate', _('Register new user with RhodeCode ' + 'with auto activation')), + ] + permission_id = Column("permission_id", Integer(), nullable=False, unique=True, default=None, primary_key=True) permission_name = Column("permission_name", String(length=255, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) permission_longname = Column("permission_longname", String(length=255, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) diff --git a/rhodecode/templates/admin/users/user_edit.html b/rhodecode/templates/admin/users/user_edit.html --- a/rhodecode/templates/admin/users/user_edit.html +++ b/rhodecode/templates/admin/users/user_edit.html @@ -186,14 +186,14 @@ %elif section == 'repositories_groups': ${k} %else: - ${k} + ${h.get_permission_name(k)} %endif %if section == 'global': - ${h.bool2icon(True)} + ${h.bool2icon(k.split('.')[-1] != 'none')} %else: - ${section_perm} + ${section_perm} %endif @@ -204,7 +204,7 @@ %endfor -
+
${_('Email addresses')}