Skip to content

Commit f5298d7

Browse files
committed
Fixed a bug in which operations were available on the /group/chartering/ 'Chartering or re-chartering' page, so that not only operations on groups in a chartering state is shown, but also the options to start chartering. Fixes issue ietf-tools#2312.
- Legacy-Id: 13584
1 parent a978567 commit f5298d7

3 files changed

Lines changed: 14 additions & 11 deletions

File tree

ietf/group/tests_info.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ def test_chartering_groups(self):
152152
q = PyQuery(r.content)
153153
self.assertEqual(len(q('#content a:contains("%s")' % group.acronym)), 1)
154154

155+
self.client.login(username="secretary", password="secretary+password")
156+
r = self.client.get(url)
157+
self.assertContains(r, "Charter new RG")
158+
155159
def test_concluded_groups(self):
156160
draft = make_test_data()
157161
group = draft.group

ietf/group/utils.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,19 @@ def save_milestone_in_history(milestone):
9292

9393
return h
9494

95-
def can_manage_group_type(user, group):
96-
if group.type_id == "rg":
95+
def can_manage_group_type(user, group, type_id=None):
96+
if type_id is None:
97+
type_id = group.type_id
98+
if type_id == "rg":
9799
return has_role(user, ('IRTF Chair', 'Secretariat'))
98-
elif group.type_id == "wg":
100+
elif type_id == "wg":
99101
return has_role(user, ('Area Director', 'Secretariat'))
100-
elif group.type_id == "team":
101-
if group.is_decendant_of("ietf"):
102+
elif type_id == "team":
103+
if group and group.is_decendant_of("ietf"):
102104
return has_role(user, ('Area Director', 'Secretariat'))
103-
elif group.is_decendant_of("irtf"):
105+
elif group and group.is_decendant_of("irtf"):
104106
return has_role(user, ('IRTF Chair', 'Secretariat'))
105-
elif group.type_id == "program":
107+
elif type_id == "program":
106108
return has_role(user, ('IAB', 'Secretariat',))
107109
return has_role(user, ('Secretariat'))
108110

ietf/group/views.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,10 +305,7 @@ def chartering_groups(request):
305305

306306
for t in group_types:
307307
t.chartering_groups = Group.objects.filter(type=t, charter__states__in=charter_states).select_related("state", "charter").order_by("acronym")
308-
if t.chartering_groups.exists():
309-
t.can_manage = can_manage_group_type(request.user, t.chartering_groups.first())
310-
else:
311-
t.can_manage = False
308+
t.can_manage = can_manage_group_type(request.user, None, t)
312309

313310
for g in t.chartering_groups:
314311
g.chartering_type = get_chartering_type(g.charter)

0 commit comments

Comments
 (0)