- %if section != 'global':
+ % if section == 'repository_branches':
${_('show')}:
- ${h.checkbox('perms_filter_none_%s' % section, 'none', 'checked', class_='perm_filter filter_%s' % section, section=section, perm_type='none')} ${_('none')}
- ${h.checkbox('perms_filter_read_%s' % section, 'read', 'checked', class_='perm_filter filter_%s' % section, section=section, perm_type='read')} ${_('read')}
- ${h.checkbox('perms_filter_write_%s' % section, 'write', 'checked', class_='perm_filter filter_%s' % section, section=section, perm_type='write')} ${_('write')}
- ${h.checkbox('perms_filter_admin_%s' % section, 'admin', 'checked', class_='perm_filter filter_%s' % section, section=section, perm_type='admin')} ${_('admin')}
+ ${h.checkbox('perms_filter_none_%s' % section, 'none', 'checked', class_='perm_filter filter_%s' % section, section=section, perm_type='none')} ${_('none')}
+ ${h.checkbox('perms_filter_merge_%s' % section, 'merge', 'checked', class_='perm_filter filter_%s' % section, section=section, perm_type='merge')} ${_('merge')}
+ ${h.checkbox('perms_filter_push_%s' % section, 'push', 'checked', class_='perm_filter filter_%s' % section, section=section, perm_type='push')} ${_('push')}
+ ${h.checkbox('perms_filter_push_force_%s' % section, 'push_force', 'checked', class_='perm_filter filter_%s' % section, section=section, perm_type='push_force')} ${_('push force')}
- %endif
+ % elif section != 'global':
+
+ ${_('show')}:
+ ${h.checkbox('perms_filter_none_%s' % section, 'none', '', class_='perm_filter filter_%s' % section, section=section, perm_type='none')} ${_('none')}
+ ${h.checkbox('perms_filter_read_%s' % section, 'read', 'checked', class_='perm_filter filter_%s' % section, section=section, perm_type='read')} ${_('read')}
+ ${h.checkbox('perms_filter_write_%s' % section, 'write', 'checked', class_='perm_filter filter_%s' % section, section=section, perm_type='write')} ${_('write')}
+ ${h.checkbox('perms_filter_admin_%s' % section, 'admin', 'checked', class_='perm_filter filter_%s' % section, section=section, perm_type='admin')} ${_('admin')}
+
+ % endif
+
@@ -72,12 +90,10 @@
%endif
%else:
%if not val_lbl:
- ${
- {'false': False,
+ ${{'false': False,
'true': True,
'none': False,
- 'repository': True}.get(val[1][0] if 0 < len(val[1]) else 'false')
- }
+ 'repository': True}.get(val[1][0] if 0 < len(val[1]) else 'false')}
%else:
${val_lbl}.${val[1][0]}
%endif
@@ -142,7 +158,72 @@
edit_url=h.route_path('user_edit_global_perms', user_id=c.user.user_id), edit_global_url=h.route_path('admin_permissions_object'))}
+ ## Branch perms
+ %elif section == 'repository_branches':
+
+
+ ${_('Name')}
+ ${_('Pattern')}
+ ${_('Permission')}
+ %if actions:
+ ${_('Edit Branch Permission')}
+ %endif
+
+
+ <%
+ def name_sorter(permissions):
+ def custom_sorter(item):
+ return item[0]
+ return sorted(permissions, key=custom_sorter)
+
+ def branch_sorter(permissions):
+ def custom_sorter(item):
+ ## none, merge, push, push_force
+ section = item[1].split('.')[-1]
+ section_importance = {'none': u'0',
+ 'merge': u'1',
+ 'push': u'2',
+ 'push_force': u'3'}.get(section)
+ ## sort by importance + name
+ return section_importance + item[0]
+ return sorted(permissions, key=custom_sorter)
+ %>
+ %for k, section_perms in name_sorter(permissions[section].items()):
+ % for pattern, perm in branch_sorter(section_perms.items()):
+
+
+ ${k}
+
+ ${pattern}
+
+ ## TODO: calculate origin somehow
+ ## % for i, ((_pat, perm), origin) in enumerate((permissions[section].perm_origin_stack[k])):
+
+
+ <% i = 0 %>
+ <% origin = 'unknown' %>
+ <% _css_class = i > 0 and 'perm_overriden' or '' %>
+
+
+ ${perm}
+ ##(${origin})
+
+
+ ## % endfor
+
+ %if actions:
+
+ ${_('edit')}
+
+ %endif
+
+ % endfor
+ %endfor
+
+
+ ## Repos/Repo Groups/users groups perms
%else:
+
## none/read/write/admin permissions on groups/repos etc
@@ -167,8 +248,11 @@
return sorted(permissions, key=custom_sorter)
%>
%for k, section_perm in sorter(permissions[section].items()):
- %if section_perm.split('.')[-1] != 'none' or show_all:
-
+ <% perm_value = section_perm.split('.')[-1] %>
+ <% _css_class = 'display:none' if perm_value in ['none'] else '' %>
+
+ %if perm_value != 'none' or show_all:
+
%if section == 'repositories':
${k}
@@ -183,7 +267,7 @@
%if hasattr(permissions[section], 'perm_origin_stack'):
%for i, (perm, origin) in enumerate(reversed(permissions[section].perm_origin_stack[k])):
-
+ <% _css_class = i > 0 and 'perm_overriden' or '' %>
% if i > 0:
@@ -193,7 +277,7 @@
% endif
-
+
${perm} (${origin})
@@ -220,7 +304,7 @@
%endfor
- ${_('No permission defined')}
+ ${_('No matching permission defined')}
@@ -236,15 +320,16 @@
diff --git a/rhodecode/templates/data_table/_dt_elements.mako b/rhodecode/templates/data_table/_dt_elements.mako
--- a/rhodecode/templates/data_table/_dt_elements.mako
+++ b/rhodecode/templates/data_table/_dt_elements.mako
@@ -284,7 +284,7 @@
<%def name="user_group_name(user_group_name)">
-
+
${h.link_to_group(user_group_name)}
%def>
diff --git a/rhodecode/templates/debug_style/tables.html b/rhodecode/templates/debug_style/tables.html
--- a/rhodecode/templates/debug_style/tables.html
+++ b/rhodecode/templates/debug_style/tables.html
@@ -534,7 +534,7 @@
- Add new
+ Add user/user group
diff --git a/rhodecode/templates/forms/mapping.pt b/rhodecode/templates/forms/mapping.pt
--- a/rhodecode/templates/forms/mapping.pt
+++ b/rhodecode/templates/forms/mapping.pt
@@ -8,12 +8,11 @@
${title}
-
-
+
+
There was a problem with this section
-
- ${errormsg}
+
+
${errormsg}
diff --git a/rhodecode/tests/models/test_permissions.py b/rhodecode/tests/models/test_permissions.py
--- a/rhodecode/tests/models/test_permissions.py
+++ b/rhodecode/tests/models/test_permissions.py
@@ -140,6 +140,10 @@ class TestPermissions(object):
assert repo_perms(user)[repo.repo_name] == 'repository.admin'
repo.user = org_owner
+ def test_default_owner_branch_perms(self, user_util, test_user_group):
+ user = user_util.create_user()
+ assert branch_perms(user) == {}
+
def test_default_owner_repo_group_perms(self, user_util, test_repo_group):
user = user_util.create_user()
org_owner = test_repo_group.user
@@ -360,13 +364,15 @@ class TestPermissions(object):
user_model.revoke_perm(self.u1, 'hg.fork.repository')
user_model.grant_perm(self.u1, 'hg.fork.none')
+ # TODO(marcink): check branch permissions now ?
+
# make sure inherit flag is turned off
self.u1.inherit_default_permissions = False
Session().commit()
# this user will have non inherited permissions from he's
# explicitly set permissions
- assert global_perms(self.u1) == set([
+ assert global_perms(self.u1) == {
'hg.create.none',
'hg.fork.none',
'hg.register.manual_activate',
@@ -375,7 +381,8 @@ class TestPermissions(object):
'repository.read',
'group.read',
'usergroup.read',
- ])
+ 'branch.push_force',
+ }
def test_non_inherited_permissions_from_default_on_user_disabled(self):
user_model = UserModel()
@@ -396,9 +403,11 @@ class TestPermissions(object):
self.u1.inherit_default_permissions = False
Session().commit()
+ # TODO(marcink): check branch perms
+
# this user will have non inherited permissions from he's
# explicitly set permissions
- assert global_perms(self.u1) == set([
+ assert global_perms(self.u1) == {
'hg.create.repository',
'hg.fork.repository',
'hg.register.manual_activate',
@@ -407,7 +416,8 @@ class TestPermissions(object):
'repository.read',
'group.read',
'usergroup.read',
- ])
+ 'branch.push_force',
+ }
@pytest.mark.parametrize('perm, expected_perm', [
('hg.inherit_default_perms.false', 'repository.none', ),
@@ -425,8 +435,10 @@ class TestPermissions(object):
self.u1.inherit_default_permissions = True
Session().commit()
+ # TODO(marcink): check branch perms
+
# this user will have inherited permissions from default user
- assert global_perms(self.u1) == set([
+ assert global_perms(self.u1) == {
'hg.create.none',
'hg.fork.none',
'hg.register.manual_activate',
@@ -435,11 +447,12 @@ class TestPermissions(object):
'repository.read',
'group.read',
'usergroup.read',
+ 'branch.push_force',
'hg.create.write_on_repogroup.true',
'hg.usergroup.create.false',
'hg.repogroup.create.false',
- perm,
- ])
+ perm
+ }
assert set(repo_perms(self.u1).values()) == set([expected_perm])
@@ -693,6 +706,11 @@ def repo_perms(user):
return auth_user.permissions['repositories']
+def branch_perms(user):
+ auth_user = AuthUser(user_id=user.user_id)
+ return auth_user.permissions['repository_branches']
+
+
def group_perms(user):
auth_user = AuthUser(user_id=user.user_id)
return auth_user.permissions['repositories_groups']
diff --git a/rhodecode/tests/vcs/test_tags.py b/rhodecode/tests/vcs/test_tags.py
--- a/rhodecode/tests/vcs/test_tags.py
+++ b/rhodecode/tests/vcs/test_tags.py
@@ -66,5 +66,5 @@ class TestTags(BackendTestMixin):
def test_name_with_slash(self):
self.repo.tag('19/10/11', 'joe')
assert '19/10/11' in self.repo.tags
- self.repo.tag('11', 'joe')
- assert '11' in self.repo.tags
+ self.repo.tag('rel.11', 'joe')
+ assert 'rel.11' in self.repo.tags