Skip to content

Commit 886296c

Browse files
committed
update security
1 parent 3bc297c commit 886296c

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

CHANGES.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
1.7.9 (unreleased)
22
------------------
33

4-
- Nothing changed yet.
4+
- update security [amleczko]
55

66

77
1.7.8 (2013-05-16)

por/dashboard/security/acl.py

+11-10
Original file line numberDiff line numberDiff line change
@@ -182,24 +182,25 @@ def __calculate_matrix__(user_id):
182182
>>> __calculate_matrix__(140)
183183
(set(['secretary'], {'fta': set(['internal_developer'])})
184184
"""
185-
from por.models import Group, User, DBSession, Project
185+
from por.models import User, DBSession, Project
186186
user = DBSession.query(User).get(user_id)
187187
global_roles = set(user.roles_names)
188188
local_roles = {}
189189
if 'administrator' in global_roles:
190190
log.debug("User: %s.\nGlobal roles: %s.\nLocal roles: %s" % (user, global_roles, local_roles))
191191
return global_roles, local_roles
192192

193-
groups = DBSession().query(Group)\
194-
.join(Group.roles)\
195-
.filter(Group.users.contains(user))
196-
for group in groups:
197-
local_roles[group.project_id] = set(group.roles_names)
193+
def add_local_role(project_id, role_name):
194+
if not project_id in local_roles:
195+
local_roles[project_id] = set()
196+
local_roles[project_id].add(role_name)
197+
198+
for group in user.groups:
199+
for role in group.roles_names:
200+
add_local_role(group.project_id, role)
198201
for project in DBSession().query(Project.id).filter(Project.manager == user):
199-
if project.id in local_roles:
200-
local_roles[project.id].add(u'project_manager')
201-
else:
202-
local_roles[project.id] = set([u'project_manager'])
202+
add_local_role(project.id, u'project_manager')
203+
203204
# extract global_roles from local_roles:
204205
roles_from_projects = set([item for sublist in local_roles.values() for item in sublist])
205206

0 commit comments

Comments
 (0)