diff --git a/ietf/group/tests_info.py b/ietf/group/tests_info.py index 4474129d2..2a1215f4d 100644 --- a/ietf/group/tests_info.py +++ b/ietf/group/tests_info.py @@ -152,6 +152,10 @@ class GroupPagesTests(TestCase): q = PyQuery(r.content) self.assertEqual(len(q('#content a:contains("%s")' % group.acronym)), 1) + self.client.login(username="secretary", password="secretary+password") + r = self.client.get(url) + self.assertContains(r, "Charter new RG") + def test_concluded_groups(self): draft = make_test_data() group = draft.group diff --git a/ietf/group/utils.py b/ietf/group/utils.py index 3a4f195ad..14acb3dc1 100644 --- a/ietf/group/utils.py +++ b/ietf/group/utils.py @@ -92,17 +92,19 @@ def save_milestone_in_history(milestone): return h -def can_manage_group_type(user, group): - if group.type_id == "rg": +def can_manage_group_type(user, group, type_id=None): + if type_id is None: + type_id = group.type_id + if type_id == "rg": return has_role(user, ('IRTF Chair', 'Secretariat')) - elif group.type_id == "wg": + elif type_id == "wg": return has_role(user, ('Area Director', 'Secretariat')) - elif group.type_id == "team": - if group.is_decendant_of("ietf"): + elif type_id == "team": + if group and group.is_decendant_of("ietf"): return has_role(user, ('Area Director', 'Secretariat')) - elif group.is_decendant_of("irtf"): + elif group and group.is_decendant_of("irtf"): return has_role(user, ('IRTF Chair', 'Secretariat')) - elif group.type_id == "program": + elif type_id == "program": return has_role(user, ('IAB', 'Secretariat',)) return has_role(user, ('Secretariat')) diff --git a/ietf/group/views.py b/ietf/group/views.py index e7f77b193..67460ecb4 100644 --- a/ietf/group/views.py +++ b/ietf/group/views.py @@ -305,10 +305,7 @@ def chartering_groups(request): for t in group_types: t.chartering_groups = Group.objects.filter(type=t, charter__states__in=charter_states).select_related("state", "charter").order_by("acronym") - if t.chartering_groups.exists(): - t.can_manage = can_manage_group_type(request.user, t.chartering_groups.first()) - else: - t.can_manage = False + t.can_manage = can_manage_group_type(request.user, None, t) for g in t.chartering_groups: g.chartering_type = get_chartering_type(g.charter)