##// END OF EJS Templates
permissions: added helper to fetch users with write permissions. Used mostly in branch protection logic.
marcink -
r4234:dbc50246 stable
parent child Browse files
Show More
@@ -21,8 +21,7 b''
21 """
21 """
22 permissions model for RhodeCode
22 permissions model for RhodeCode
23 """
23 """
24
24 import collections
25
26 import logging
25 import logging
27 import traceback
26 import traceback
28
27
@@ -557,6 +556,27 b' class PermissionModel(BaseModel):'
557 self.sa.rollback()
556 self.sa.rollback()
558 raise
557 raise
559
558
559 def get_users_with_repo_write(self, db_repo):
560 write_plus = ['repository.write', 'repository.admin']
561 default_user_id = User.get_default_user().user_id
562 user_write_permissions = collections.OrderedDict()
563
564 # write+ and DEFAULT user for inheritance
565 for perm in db_repo.permissions():
566 if perm.permission in write_plus or perm.user_id == default_user_id:
567 user_write_permissions[perm.user_id] = perm
568 return user_write_permissions
569
570 def get_user_groups_with_repo_write(self, db_repo):
571 write_plus = ['repository.write', 'repository.admin']
572 user_group_write_permissions = collections.OrderedDict()
573
574 # write+ and DEFAULT user for inheritance
575 for p in db_repo.permission_user_groups():
576 if p.permission in write_plus:
577 user_group_write_permissions[p.users_group_id] = p
578 return user_group_write_permissions
579
560 def trigger_permission_flush(self, affected_user_ids):
580 def trigger_permission_flush(self, affected_user_ids):
561 events.trigger(events.UserPermissionsChange(affected_user_ids))
581 events.trigger(events.UserPermissionsChange(affected_user_ids))
562
582
General Comments 0
You need to be logged in to leave comments. Login now