Fixed a place where a logged-in user without associcated Person would cause a 500 instead of 403.

- Legacy-Id: 11474
This commit is contained in:
Henrik Levkowetz 2016-06-25 20:27:13 +00:00
parent 834bf08d6f
commit 51b68099a5

View file

@ -18,26 +18,27 @@ def check_access(user):
This function takes a Django User object and returns true if the user has access to This function takes a Django User object and returns true if the user has access to
the Announcement app. the Announcement app.
''' '''
person = user.person if hasattr(user, "person"):
groups_with_access = ("iab", "isoc", "isocbot", "rsoc", "ietf", "iaoc", "rse", "mentor","ietf-trust") person = user.person
if Role.objects.filter(person=person, groups_with_access = ("iab", "isoc", "isocbot", "rsoc", "ietf", "iaoc", "rse", "mentor","ietf-trust")
group__acronym__in=groups_with_access, if Role.objects.filter(person=person,
name="chair") or has_role(user, ["Secretariat","IAD"]): group__acronym__in=groups_with_access,
return True name="chair") or has_role(user, ["Secretariat","IAD"]):
if Role.objects.filter(name="chair", return True
group__acronym__startswith="nomcom", if Role.objects.filter(name="chair",
group__state="active", group__acronym__startswith="nomcom",
group__type="nomcom", group__state="active",
person=person): group__type="nomcom",
return True person=person):
if Role.objects.filter(person=person, return True
group__acronym='iab', if Role.objects.filter(person=person,
name='execdir'): group__acronym='iab',
return True name='execdir'):
if Role.objects.filter(person=person, return True
group__acronym='isoc', if Role.objects.filter(person=person,
name='ceo'): group__acronym='isoc',
return True name='ceo'):
return True
return False return False