Skip to content

Commit

Permalink
[#1965] First version of React results framework
Browse files Browse the repository at this point in the history
  • Loading branch information
KasperBrandt committed Feb 2, 2016
1 parent 8d57677 commit 68dfe3e
Show file tree
Hide file tree
Showing 7 changed files with 873 additions and 541 deletions.
27 changes: 23 additions & 4 deletions akvo/rsr/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,12 +388,31 @@ def employments_dict(self, org_list):
employments=employments_array,
)

def has_role_in_org(self, org, group):
"""
Helper function to determine if a user is in a certain group at an organisation.
:param org; an Organisation instance.
:param group; a Group instance.
"""
if self.approved_employments().filter(organisation=org, group=group).exists():
return True
return False

def admin_of(self, org):
"""
Checks if the user is an Admin of this organisation.
:param org; an Organisation instance.
"""
admin_group = Group.objects.get(name='Admins')
for employment in Employment.objects.filter(user=self, group=admin_group):
if employment.organisation == org:
return True
return False
return self.has_role_in_org(org, admin_group)

def project_editor_of(self, org):
"""
Checks if the user is a Project editor of this organisation.
:param org; an Organisation instance
"""
editor_group = Group.objects.get(name='Project editors')
return self.has_role_in_org(org, editor_group)
Loading

0 comments on commit 68dfe3e

Please sign in to comment.