Skip to content

Commit 95afaeb

Browse files
committed
Accounts authorized to sumbit liaison statements. See ietf-tools#343
- Legacy-Id: 2331
1 parent 96cb4ac commit 95afaeb

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

ietf/liaisons/accounts.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
from ietf.idtracker.models import Role
2+
3+
4+
def get_person_for_user(user):
5+
return user.get_profile().person()
6+
7+
8+
def is_areadirector(person):
9+
return bool(person.areadirector_set.all())
10+
11+
12+
def is_wgchair(person):
13+
return bool(person.wgchair_set.all())
14+
15+
16+
def is_wgsecretary(person):
17+
return bool(person.wgsecretary_set.all())
18+
19+
20+
def has_role(person, role):
21+
return bool(person.role_set.filter(pk=role))
22+
23+
24+
def is_ietfchair(person):
25+
return has_role(person, Role.IETF_CHAIR)
26+
27+
28+
def is_iabchair(person):
29+
return has_role(person, Role.IAB_CHAIR)
30+
31+
32+
def is_iab_executive_director(person):
33+
return has_role(person, Role.IAB_EXCUTIVE_DIRECTOR)
34+
35+
36+
def can_add_liaison(user):
37+
person = get_person_for_user(user)
38+
if not person:
39+
return False
40+
41+
if (is_areadirector(person) or is_wgchair(person) or
42+
is_wgsecretary(person) or is_ietfchair(person) or
43+
is_iabchair(person) or is_iab_executive_director(person)):
44+
return True
45+
return False

ietf/liaisons/decorators.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from ietf.ietfauth.decorators import _CheckLogin403
2+
from ietf.liaisons.accounts import can_add_liaison
3+
4+
5+
def can_submit_liaison(view_func=None):
6+
7+
def decorate(view_func):
8+
return _CheckLogin403(
9+
view_func,
10+
lambda u: can_add_liaison(u),
11+
"Restricted to participants who are authorized to submit liaison statements on behalf of the various IETF entities")
12+
if view_func:
13+
return decorate(view_func)
14+
return decorate

0 commit comments

Comments
 (0)