Show More
@@ -67,7 +67,6 b' class LoginController(BaseController):' | |||||
67 | user_model = UserModel() |
|
67 | user_model = UserModel() | |
68 | c.auto_active = False |
|
68 | c.auto_active = False | |
69 | for perm in user_model.get_default().user_perms: |
|
69 | for perm in user_model.get_default().user_perms: | |
70 | print perm.permission.permission_name |
|
|||
71 | if perm.permission.permission_name == 'hg.register.auto_activate': |
|
70 | if perm.permission.permission_name == 'hg.register.auto_activate': | |
72 | c.auto_active = True |
|
71 | c.auto_active = True | |
73 | break |
|
72 | break |
@@ -124,8 +124,6 b' def fill_data(user):' | |||||
124 | else: |
|
124 | else: | |
125 | user.is_authenticated = False |
|
125 | user.is_authenticated = False | |
126 | meta.Session.remove() |
|
126 | meta.Session.remove() | |
127 | from pprint import pprint |
|
|||
128 | pprint(user.permissions) |
|
|||
129 | return user |
|
127 | return user | |
130 |
|
128 | |||
131 | def fill_perms(user): |
|
129 | def fill_perms(user): | |
@@ -141,16 +139,15 b' def fill_perms(user):' | |||||
141 | #=========================================================================== |
|
139 | #=========================================================================== | |
142 | # fetch default permissions |
|
140 | # fetch default permissions | |
143 | #=========================================================================== |
|
141 | #=========================================================================== | |
144 |
default_perms = sa.query(RepoToPerm, |
|
142 | default_perms = sa.query(RepoToPerm, Repository, Permission)\ | |
145 | .outerjoin((UserToPerm, RepoToPerm.user_id == UserToPerm.user_id))\ |
|
|||
146 | .join((Repository, RepoToPerm.repository_id == Repository.repo_id))\ |
|
143 | .join((Repository, RepoToPerm.repository_id == Repository.repo_id))\ | |
147 | .join((Permission, RepoToPerm.permission_id == Permission.permission_id))\ |
|
144 | .join((Permission, RepoToPerm.permission_id == Permission.permission_id))\ | |
148 |
.filter(RepoToPerm.user |
|
145 | .filter(RepoToPerm.user == sa.query(User).filter(User.username == | |
149 |
'default'). |
|
146 | 'default').scalar()).all() | |
150 |
|
147 | |||
151 | if user.is_admin: |
|
148 | if user.is_admin: | |
152 | #======================================================================= |
|
149 | #======================================================================= | |
153 | # #admin have all rights set to admin |
|
150 | # #admin have all default rights set to admin | |
154 | #======================================================================= |
|
151 | #======================================================================= | |
155 | user.permissions['global'].add('hg.admin') |
|
152 | user.permissions['global'].add('hg.admin') | |
156 |
|
153 | |||
@@ -164,8 +161,12 b' def fill_perms(user):' | |||||
164 | #======================================================================= |
|
161 | #======================================================================= | |
165 |
|
162 | |||
166 | #default global |
|
163 | #default global | |
167 | for perm in default_perms: |
|
164 | default_global_perms = sa.query(UserToPerm)\ | |
168 | user.permissions['global'].add(perm.UserToPerm.permission.permission_name) |
|
165 | .filter(UserToPerm.user == sa.query(User).filter(User.username == | |
|
166 | 'default').one()) | |||
|
167 | ||||
|
168 | for perm in default_global_perms: | |||
|
169 | user.permissions['global'].add(perm.permission.permission_name) | |||
169 |
|
170 | |||
170 | #default repositories |
|
171 | #default repositories | |
171 | for perm in default_perms: |
|
172 | for perm in default_perms: | |
@@ -183,8 +184,7 b' def fill_perms(user):' | |||||
183 | #======================================================================= |
|
184 | #======================================================================= | |
184 | # #overwrite default with user permissions if any |
|
185 | # #overwrite default with user permissions if any | |
185 | #======================================================================= |
|
186 | #======================================================================= | |
186 |
user_perms = sa.query(RepoToPerm, |
|
187 | user_perms = sa.query(RepoToPerm, Permission, Repository)\ | |
187 | .outerjoin((UserToPerm, RepoToPerm.user_id == UserToPerm.user_id))\ |
|
|||
188 | .join((Repository, RepoToPerm.repository_id == Repository.repo_id))\ |
|
188 | .join((Repository, RepoToPerm.repository_id == Repository.repo_id))\ | |
189 | .join((Permission, RepoToPerm.permission_id == Permission.permission_id))\ |
|
189 | .join((Permission, RepoToPerm.permission_id == Permission.permission_id))\ | |
190 | .filter(RepoToPerm.user_id == user.user_id).all() |
|
190 | .filter(RepoToPerm.user_id == user.user_id).all() |
General Comments 0
You need to be logged in to leave comments.
Login now