Skip to content

Commit

Permalink
[#1365] Permissions for Akvo Pages (not working)
Browse files Browse the repository at this point in the history
  • Loading branch information
KasperBrandt committed Apr 1, 2015
1 parent a4ccab4 commit 6f2c809
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion akvo/rsr/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
rules.add_perm('rsr.change_keyword', is_rsr_admin)

rules.add_perm('rsr.add_partnersite', is_rsr_admin)
rules.add_perm('rsr.change_partnersite', is_rsr_admin)
rules.add_perm('rsr.change_partnersite', is_rsr_admin | is_org_admin)

rules.add_perm('rsr.add_partnertype', is_rsr_admin)
rules.add_perm('rsr.change_partnertype', is_rsr_admin)
Expand Down
5 changes: 4 additions & 1 deletion akvo/rsr/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from django.contrib.auth import get_user_model
from django.contrib.auth.models import Group

from .models import Employment, Organisation, Project, PublishingStatus
from .models import Employment, Organisation, PartnerSite, Project, PublishingStatus


@rules.predicate
Expand All @@ -20,6 +20,7 @@ def is_rsr_admin(user):

@rules.predicate
def is_org_admin(user, obj):
# obj + 1
if not user.is_authenticated():
return False
for employment in user.employers.approved():
Expand All @@ -36,6 +37,8 @@ def is_org_admin(user, obj):
return True
elif isinstance(obj, PublishingStatus) and obj in employment.organisation.all_projects().publishingstatuses():
return True
elif isinstance(obj, PartnerSite) and obj in employment.organisation.partnersites():
return True
else:
try:
if obj.project and obj.project in employment.organisation.all_projects():
Expand Down

0 comments on commit 6f2c809

Please sign in to comment.