##// END OF EJS Templates
fixed tests and missing replacements from 5f1850e4712a
marcink -
r3415:b8f929bf beta
parent child Browse files
Show More
@@ -411,7 +411,7 b' class AuthUser(object):'
411 411 @property
412 412 def groups_admin(self):
413 413 """
414 Returns list of repositories groups you're an admin of
414 Returns list of repository groups you're an admin of
415 415 """
416 416 return [x[0] for x in self.permissions['repositories_groups'].iteritems()
417 417 if x[1] == 'group.admin']
@@ -684,9 +684,9 b' def action_parser(user_log, feed=False, '
684 684 get_user_name, 'user_add.png'),
685 685 'admin_updated_user': (_('[updated] user'),
686 686 get_user_name, 'user_edit.png'),
687 'admin_created_users_group': (_('[created] users group'),
687 'admin_created_users_group': (_('[created] user group'),
688 688 get_users_group, 'group_add.png'),
689 'admin_updated_users_group': (_('[updated] users group'),
689 'admin_updated_users_group': (_('[updated] user group'),
690 690 get_users_group, 'group_edit.png'),
691 691 'user_commented_revision': (_('[commented] on revision in repository'),
692 692 get_cs_links, 'comment_add.png'),
@@ -549,12 +549,12 b' class RepoModel(BaseModel):'
549 549
550 550 def grant_users_group_permission(self, repo, group_name, perm):
551 551 """
552 Grant permission for users group on given repository, or update
552 Grant permission for user group on given repository, or update
553 553 existing one if found
554 554
555 555 :param repo: Instance of Repository, repository_id, or repository name
556 556 :param group_name: Instance of UserGroup, users_group_id,
557 or users group name
557 or user group name
558 558 :param perm: Instance of Permission, or permission_name
559 559 """
560 560 repo = self._get_repo(repo)
@@ -579,11 +579,11 b' class RepoModel(BaseModel):'
579 579
580 580 def revoke_users_group_permission(self, repo, group_name):
581 581 """
582 Revoke permission for users group on given repository
582 Revoke permission for user group on given repository
583 583
584 584 :param repo: Instance of Repository, repository_id, or repository name
585 585 :param group_name: Instance of UserGroup, users_group_id,
586 or users group name
586 or user group name
587 587 """
588 588 repo = self._get_repo(repo)
589 589 group_name = self.__get_users_group(group_name)
@@ -512,7 +512,7 b' class UserModel(BaseModel):'
512 512 'hg.create.none', 'hg.create.repository'])
513 513
514 514 # USER GROUPS comes first
515 # users group global permissions
515 # user group global permissions
516 516 user_perms_from_users_groups = self.sa.query(UsersGroupToPerm)\
517 517 .options(joinedload(UsersGroupToPerm.permission))\
518 518 .join((UsersGroupMember, UsersGroupToPerm.users_group_id ==
@@ -559,7 +559,7 b' class UserModel(BaseModel):'
559 559 # permission should be selected based on selected method
560 560 #======================================================================
561 561
562 # users group for repositories permissions
562 # user group for repositories permissions
563 563 user_repo_perms_from_users_groups = \
564 564 self.sa.query(UsersGroupRepoToPerm, Permission, Repository,)\
565 565 .join((Repository, UsersGroupRepoToPerm.repository_id ==
@@ -617,7 +617,7 b' class UserModel(BaseModel):'
617 617 # fill in his permission from it. _choose_perm decides of which
618 618 # permission should be selected based on selected method
619 619 #======================================================================
620 # users group for repo groups permissions
620 # user group for repo groups permissions
621 621 user_repo_group_perms_from_users_groups = \
622 622 self.sa.query(UsersGroupRepoGroupToPerm, Permission, RepoGroup)\
623 623 .join((RepoGroup, UsersGroupRepoGroupToPerm.group_id == RepoGroup.group_id))\
@@ -132,10 +132,10 b' def ValidRepoUser():'
132 132 def ValidUsersGroup(edit=False, old_data={}):
133 133 class _validator(formencode.validators.FancyValidator):
134 134 messages = {
135 'invalid_group': _(u'Invalid users group name'),
135 'invalid_group': _(u'Invalid user group name'),
136 136 'group_exist': _(u'Users group "%(usersgroup)s" already exists'),
137 137 'invalid_usersgroup_name':
138 _(u'users group name may only contain alphanumeric '
138 _(u'user group name may only contain alphanumeric '
139 139 'characters underscores, periods or dashes and must begin '
140 140 'with alphanumeric character')
141 141 }
@@ -547,7 +547,7 b" def ValidPerms(type_='repo'):"
547 547 class _validator(formencode.validators.FancyValidator):
548 548 messages = {
549 549 'perm_new_member_name':
550 _(u'This username or users group name is not valid')
550 _(u'This username or user group name is not valid')
551 551 }
552 552
553 553 def to_python(self, value, state):
@@ -9,7 +9,7 b''
9 9 <%def name="breadcrumbs_links()">
10 10 ${h.link_to(_('Admin'),h.url('admin_home'))}
11 11 &raquo;
12 ${_('repositories groups')}
12 ${_('repository groups')}
13 13 </%def>
14 14 <%def name="page_nav()">
15 15 ${self.menu('admin')}
@@ -2,7 +2,7 b''
2 2 <%inherit file="/base/base.html"/>
3 3
4 4 <%def name="title()">
5 ${_('Edit users group')} ${c.users_group.users_group_name} - ${c.rhodecode_name}
5 ${_('Edit user group')} ${c.users_group.users_group_name} - ${c.rhodecode_name}
6 6 </%def>
7 7
8 8 <%def name="breadcrumbs_links()">
@@ -1037,7 +1037,7 b' class BaseTestApi(object):'
1037 1037 response = api_call(self, params)
1038 1038
1039 1039 ret = {
1040 'msg': 'created new users group `%s`' % group_name,
1040 'msg': 'created new user group `%s`' % group_name,
1041 1041 'users_group': jsonify(UsersGroupModel()\
1042 1042 .get_by_name(group_name)\
1043 1043 .get_api_data())
@@ -1052,7 +1052,7 b' class BaseTestApi(object):'
1052 1052 group_name=TEST_USERS_GROUP)
1053 1053 response = api_call(self, params)
1054 1054
1055 expected = "users group `%s` already exist" % TEST_USERS_GROUP
1055 expected = "user group `%s` already exist" % TEST_USERS_GROUP
1056 1056 self._compare_error(id_, expected, given=response.body)
1057 1057
1058 1058 @mock.patch.object(UsersGroupModel, 'create', crash)
@@ -1075,7 +1075,7 b' class BaseTestApi(object):'
1075 1075 response = api_call(self, params)
1076 1076
1077 1077 expected = {
1078 'msg': 'added member `%s` to users group `%s`' % (
1078 'msg': 'added member `%s` to user group `%s`' % (
1079 1079 TEST_USER_ADMIN_LOGIN, gr_name
1080 1080 ),
1081 1081 'success': True}
@@ -1090,7 +1090,7 b' class BaseTestApi(object):'
1090 1090 userid=TEST_USER_ADMIN_LOGIN)
1091 1091 response = api_call(self, params)
1092 1092
1093 expected = 'users group `%s` does not exist' % 'false-group'
1093 expected = 'user group `%s` does not exist' % 'false-group'
1094 1094 self._compare_error(id_, expected, given=response.body)
1095 1095
1096 1096 @mock.patch.object(UsersGroupModel, 'add_user_to_group', crash)
@@ -1103,7 +1103,7 b' class BaseTestApi(object):'
1103 1103 userid=TEST_USER_ADMIN_LOGIN)
1104 1104 response = api_call(self, params)
1105 1105
1106 expected = 'failed to add member to users group `%s`' % gr_name
1106 expected = 'failed to add member to user group `%s`' % gr_name
1107 1107 self._compare_error(id_, expected, given=response.body)
1108 1108
1109 1109 UsersGroupModel().delete(users_group=gr_name)
@@ -1120,7 +1120,7 b' class BaseTestApi(object):'
1120 1120 response = api_call(self, params)
1121 1121
1122 1122 expected = {
1123 'msg': 'removed member `%s` from users group `%s`' % (
1123 'msg': 'removed member `%s` from user group `%s`' % (
1124 1124 TEST_USER_ADMIN_LOGIN, gr_name
1125 1125 ),
1126 1126 'success': True}
@@ -1140,7 +1140,7 b' class BaseTestApi(object):'
1140 1140 userid=TEST_USER_ADMIN_LOGIN)
1141 1141 response = api_call(self, params)
1142 1142
1143 expected = 'failed to remove member from users group `%s`' % gr_name
1143 expected = 'failed to remove member from user group `%s`' % gr_name
1144 1144 self._compare_error(id_, expected, given=response.body)
1145 1145
1146 1146 UsersGroupModel().delete(users_group=gr_name)
@@ -1229,7 +1229,7 b' class BaseTestApi(object):'
1229 1229 response = api_call(self, params)
1230 1230
1231 1231 ret = {
1232 'msg': 'Granted perm: `%s` for users group: `%s` in repo: `%s`' % (
1232 'msg': 'Granted perm: `%s` for user group: `%s` in repo: `%s`' % (
1233 1233 perm, TEST_USERS_GROUP, self.REPO
1234 1234 ),
1235 1235 'success': True
@@ -1257,7 +1257,7 b' class BaseTestApi(object):'
1257 1257 perm=perm)
1258 1258 response = api_call(self, params)
1259 1259
1260 expected = 'failed to edit permission for users group: `%s` in repo: `%s`' % (
1260 expected = 'failed to edit permission for user group: `%s` in repo: `%s`' % (
1261 1261 TEST_USERS_GROUP, self.REPO
1262 1262 )
1263 1263 self._compare_error(id_, expected, given=response.body)
@@ -1273,7 +1273,7 b' class BaseTestApi(object):'
1273 1273 response = api_call(self, params)
1274 1274
1275 1275 expected = {
1276 'msg': 'Revoked perm for users group: `%s` in repo: `%s`' % (
1276 'msg': 'Revoked perm for user group: `%s` in repo: `%s`' % (
1277 1277 TEST_USERS_GROUP, self.REPO
1278 1278 ),
1279 1279 'success': True
@@ -1288,7 +1288,7 b' class BaseTestApi(object):'
1288 1288 usersgroupid=TEST_USERS_GROUP,)
1289 1289 response = api_call(self, params)
1290 1290
1291 expected = 'failed to edit permission for users group: `%s` in repo: `%s`' % (
1291 expected = 'failed to edit permission for user group: `%s` in repo: `%s`' % (
1292 1292 TEST_USERS_GROUP, self.REPO
1293 1293 )
1294 1294 self._compare_error(id_, expected, given=response.body)
@@ -22,7 +22,7 b' class TestAdminUsersGroupsController(Tes'
22 22 response.follow()
23 23
24 24 self.checkSessionFlash(response,
25 'created users group %s' % TEST_USERS_GROUP)
25 'created user group %s' % TEST_USERS_GROUP)
26 26
27 27 def test_new(self):
28 28 response = self.app.get(url('new_users_group'))
@@ -46,7 +46,7 b' class TestAdminUsersGroupsController(Tes'
46 46 response.follow()
47 47
48 48 self.checkSessionFlash(response,
49 'created users group %s' % users_group_name)
49 'created user group %s' % users_group_name)
50 50
51 51 gr = self.Session.query(UsersGroup)\
52 52 .filter(UsersGroup.users_group_name ==
@@ -70,7 +70,7 b' class TestAdminUsersGroupsController(Tes'
70 70
71 71 ug = UsersGroup.get_by_group_name(users_group_name)
72 72 self.checkSessionFlash(response,
73 'created users group %s' % users_group_name)
73 'created user group %s' % users_group_name)
74 74 ## ENABLE REPO CREATE ON A GROUP
75 75 response = self.app.put(url('users_group_perm', id=ug.users_group_id),
76 76 {'create_repo_perm': True})
@@ -139,7 +139,7 b' class TestAdminUsersGroupsController(Tes'
139 139
140 140 ug = UsersGroup.get_by_group_name(users_group_name)
141 141 self.checkSessionFlash(response,
142 'created users group %s' % users_group_name)
142 'created user group %s' % users_group_name)
143 143 ## ENABLE REPO CREATE ON A GROUP
144 144 response = self.app.put(url('users_group_perm', id=ug.users_group_id),
145 145 {'fork_repo_perm': True})
@@ -439,7 +439,7 b' class TestPermissions(unittest.TestCase)'
439 439 u1_auth = AuthUser(user_id=self.u1.user_id)
440 440 self.assertEqual(u1_auth.permissions['repositories']['myownrepo'],
441 441 'repository.admin')
442 #set his permission as users group, he should still be admin
442 #set his permission as user group, he should still be admin
443 443 self.ug1 = UsersGroupModel().create('G1')
444 444 # add user to group
445 445 UsersGroupModel().add_user_to_group(self.ug1, self.u1)
@@ -22,7 +22,7 b' class TestUser(unittest.TestCase):'
22 22 Session().commit()
23 23 self.assertEqual(User.get_by_username(u'test_user'), usr)
24 24
25 # make users group
25 # make user group
26 26 users_group = UsersGroupModel().create('some_example_group')
27 27 Session().commit()
28 28
General Comments 0
You need to be logged in to leave comments. Login now