##// END OF EJS Templates
fixes #30. Rewrite default permissions query + some other small fixes
marcink -
r423:16253f33 default
parent child Browse files
Show More
@@ -141,16 +141,15 b' def fill_perms(user):'
141 #===========================================================================
141 #===========================================================================
142 # fetch default permissions
142 # fetch default permissions
143 #===========================================================================
143 #===========================================================================
144 default_perms = sa.query(RepoToPerm, UserToPerm, Repository, Permission)\
144 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))\
145 .join((Repository, RepoToPerm.repository_id == Repository.repo_id))\
147 .join((Permission, RepoToPerm.permission_id == Permission.permission_id))\
146 .join((Permission, RepoToPerm.permission_id == Permission.permission_id))\
148 .filter(RepoToPerm.user_id == sa.query(User).filter(User.username ==
147 .filter(RepoToPerm.user == sa.query(User).filter(User.username ==
149 'default').one().user_id).all()
148 'default').scalar()).all()
150
149
151 if user.is_admin:
150 if user.is_admin:
152 #=======================================================================
151 #=======================================================================
153 # #admin have all rights set to admin
152 # #admin have all default rights set to admin
154 #=======================================================================
153 #=======================================================================
155 user.permissions['global'].add('hg.admin')
154 user.permissions['global'].add('hg.admin')
156
155
@@ -164,8 +163,12 b' def fill_perms(user):'
164 #=======================================================================
163 #=======================================================================
165
164
166 #default global
165 #default global
167 for perm in default_perms:
166 default_global_perms = sa.query(UserToPerm)\
168 user.permissions['global'].add(perm.UserToPerm.permission.permission_name)
167 .filter(UserToPerm.user == sa.query(User).filter(User.username ==
168 'default').one())
169
170 for perm in default_global_perms:
171 user.permissions['global'].add(perm.permission.permission_name)
169
172
170 #default repositories
173 #default repositories
171 for perm in default_perms:
174 for perm in default_perms:
@@ -183,8 +186,7 b' def fill_perms(user):'
183 #=======================================================================
186 #=======================================================================
184 # #overwrite default with user permissions if any
187 # #overwrite default with user permissions if any
185 #=======================================================================
188 #=======================================================================
186 user_perms = sa.query(RepoToPerm, UserToPerm, Permission, Repository)\
189 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))\
190 .join((Repository, RepoToPerm.repository_id == Repository.repo_id))\
189 .join((Permission, RepoToPerm.permission_id == Permission.permission_id))\
191 .join((Permission, RepoToPerm.permission_id == Permission.permission_id))\
190 .filter(RepoToPerm.user_id == user.user_id).all()
192 .filter(RepoToPerm.user_id == user.user_id).all()
General Comments 0
You need to be logged in to leave comments. Login now