Show More
@@ -31,7 +31,8 b' from sqlalchemy.exc import DatabaseError' | |||||
31 | from rhodecode.lib.caching_query import FromCache |
|
31 | from rhodecode.lib.caching_query import FromCache | |
32 |
|
32 | |||
33 | from rhodecode.model import BaseModel |
|
33 | from rhodecode.model import BaseModel | |
34 | from rhodecode.model.db import User, Permission, UserToPerm, UserRepoToPerm |
|
34 | from rhodecode.model.db import User, Permission, UserToPerm, UserRepoToPerm,\ | |
|
35 | UserRepoGroupToPerm | |||
35 |
|
36 | |||
36 | log = logging.getLogger(__name__) |
|
37 | log = logging.getLogger(__name__) | |
37 |
|
38 | |||
@@ -87,23 +88,33 b' class PermissionModel(BaseModel):' | |||||
87 | form_result['default_perm']) |
|
88 | form_result['default_perm']) | |
88 | self.sa.add(p) |
|
89 | self.sa.add(p) | |
89 |
|
90 | |||
90 | if p.permission.permission_name.startswith('hg.register.'): |
|
91 | elif p.permission.permission_name.startswith('hg.register.'): | |
91 | p.permission = self.get_permission_by_name( |
|
92 | p.permission = self.get_permission_by_name( | |
92 | form_result['default_register']) |
|
93 | form_result['default_register']) | |
93 | self.sa.add(p) |
|
94 | self.sa.add(p) | |
94 |
|
95 | |||
95 | if p.permission.permission_name.startswith('hg.create.'): |
|
96 | elif p.permission.permission_name.startswith('hg.create.'): | |
96 | p.permission = self.get_permission_by_name( |
|
97 | p.permission = self.get_permission_by_name( | |
97 | form_result['default_create']) |
|
98 | form_result['default_create']) | |
98 | self.sa.add(p) |
|
99 | self.sa.add(p) | |
99 |
|
100 | |||
|
101 | _def_name = form_result['default_perm'].split('repository.')[-1] | |||
100 | #stage 2 update all default permissions for repos if checked |
|
102 | #stage 2 update all default permissions for repos if checked | |
101 | if form_result['overwrite_default'] == True: |
|
103 | if form_result['overwrite_default'] == True: | |
|
104 | _def = self.get_permission_by_name('repository.' + _def_name) | |||
|
105 | # repos | |||
102 | for r2p in self.sa.query(UserRepoToPerm)\ |
|
106 | for r2p in self.sa.query(UserRepoToPerm)\ | |
103 |
.filter(UserRepoToPerm.user == perm_user) |
|
107 | .filter(UserRepoToPerm.user == perm_user)\ | |
104 | r2p.permission = self.get_permission_by_name( |
|
108 | .all(): | |
105 | form_result['default_perm']) |
|
109 | r2p.permission = _def | |
106 | self.sa.add(r2p) |
|
110 | self.sa.add(r2p) | |
|
111 | # groups | |||
|
112 | _def = self.get_permission_by_name('group.' + _def_name) | |||
|
113 | for g2p in self.sa.query(UserRepoGroupToPerm)\ | |||
|
114 | .filter(UserRepoGroupToPerm.user == perm_user)\ | |||
|
115 | .all(): | |||
|
116 | g2p.permission = _def | |||
|
117 | self.sa.add(g2p) | |||
107 |
|
118 | |||
108 | # stage 3 set anonymous access |
|
119 | # stage 3 set anonymous access | |
109 | if perm_user.username == 'default': |
|
120 | if perm_user.username == 'default': |
General Comments 0
You need to be logged in to leave comments.
Login now