Change announcement tool access function to use data from AnnouncementFrom objects. Fixes #2362. Commit ready for merge
- Legacy-Id: 14103
This commit is contained in:
parent
044b89169a
commit
a85a76247a
|
@ -4,6 +4,7 @@ from django.http import HttpResponseForbidden
|
||||||
from django.shortcuts import render, redirect
|
from django.shortcuts import render, redirect
|
||||||
|
|
||||||
from ietf.group.models import Role
|
from ietf.group.models import Role
|
||||||
|
from ietf.message.models import AnnouncementFrom
|
||||||
from ietf.ietfauth.utils import has_role
|
from ietf.ietfauth.utils import has_role
|
||||||
from ietf.secr.announcement.forms import AnnounceForm
|
from ietf.secr.announcement.forms import AnnounceForm
|
||||||
from ietf.secr.utils.decorators import check_for_cancel
|
from ietf.secr.utils.decorators import check_for_cancel
|
||||||
|
@ -19,25 +20,19 @@ def check_access(user):
|
||||||
'''
|
'''
|
||||||
if hasattr(user, "person"):
|
if hasattr(user, "person"):
|
||||||
person = user.person
|
person = user.person
|
||||||
groups_with_access = ("iab", "isoc", "isocbot", "rsoc", "ietf", "iaoc", "rse", "mentor","ietf-trust")
|
if has_role(user, "Secretariat"):
|
||||||
if Role.objects.filter(person=person,
|
|
||||||
group__acronym__in=groups_with_access,
|
|
||||||
name="chair") or has_role(user, ["Secretariat","IAD"]):
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
for role in person.role_set.all():
|
||||||
|
if AnnouncementFrom.objects.filter(name=role.name,group=role.group):
|
||||||
|
return True
|
||||||
|
|
||||||
if Role.objects.filter(name="chair",
|
if Role.objects.filter(name="chair",
|
||||||
group__acronym__startswith="nomcom",
|
group__acronym__startswith="nomcom",
|
||||||
group__state="active",
|
group__state="active",
|
||||||
group__type="nomcom",
|
group__type="nomcom",
|
||||||
person=person):
|
person=person):
|
||||||
return True
|
return True
|
||||||
if Role.objects.filter(person=person,
|
|
||||||
group__acronym='iab',
|
|
||||||
name='execdir'):
|
|
||||||
return True
|
|
||||||
if Role.objects.filter(person=person,
|
|
||||||
group__acronym='isoc',
|
|
||||||
name='ceo'):
|
|
||||||
return True
|
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue