Skip to content

Commit 5924024

Browse files
committed
Swap the arguments to group.has_role so they match the arguments to
the existing has_role - Legacy-Id: 6218
1 parent 0eed4ad commit 5924024

3 files changed

Lines changed: 6 additions & 4 deletions

File tree

ietf/group/models.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,10 @@ def latest_event(self, *args, **filter_args):
5454
e = model.objects.filter(group=self).filter(**filter_args).order_by('-time', '-id')[:1]
5555
return e[0] if e else None
5656

57-
def has_role(self, role_name, user):
58-
return user.is_authenticated() and self.role_set.filter(name=role_name, person__user=user).exists()
57+
def has_role(self, user, role_names):
58+
if isinstance(role_names, str) or isinstance(role_names, unicode):
59+
role_names = [role_names]
60+
return user.is_authenticated() and self.role_set.filter(name__in=role_names, person__user=user).exists()
5961

6062
def get_chair(self):
6163
chair = self.role_set.filter(name__slug='chair')[:1]

ietf/nomcom/templatetags/nomcom_tags.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def is_chair(user, year):
2424
nomcom = get_nomcom_by_year(year=year)
2525
if has_role(user, "Secretariat"):
2626
return True
27-
return nomcom.group.has_role("chair", user)
27+
return nomcom.group.has_role(user, "chair")
2828

2929

3030
@register.filter

ietf/nomcom/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def private_key(request, year):
8181
def private_index(request, year):
8282
nomcom = get_nomcom_by_year(year)
8383
all_nominee_positions = NomineePosition.objects.get_by_nomcom(nomcom).not_duplicated()
84-
is_chair = nomcom.group.has_role("chair", request.user)
84+
is_chair = nomcom.group.has_role(request.user, "chair")
8585
message = None
8686
if is_chair and request.method == 'POST':
8787
action = request.POST.get('action')

0 commit comments

Comments
 (0)