Skip to content

Commit

Permalink
Improve perm for group
Browse files Browse the repository at this point in the history
  • Loading branch information
tizot committed Feb 1, 2016
1 parent 64e8a20 commit d0a27bd
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion sigma_core/models/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,15 @@ def has_create_permission(request):
"""
from sigma_core.models.school import School
group_type = request.data.get('type', None)
if group_type == Group.TYPE_BASIC:
return True

resp_school = request.data.get('resp_school', None)
try:
school = School.objects.get(pk=resp_school)
except School.DoesNotExist:
school = None
return group_type == Group.TYPE_BASIC or (school is not None and request.user.has_group_admin_perm(school))
return school is not None and request.user.has_group_admin_perm(school)

@allow_staff_or_superuser
def has_object_write_permission(self, request):
Expand Down

0 comments on commit d0a27bd

Please sign in to comment.