Skip to content

Commit 14dd4cf

Browse files
authored
feat: show parents on list of teams with grouping (#8635) (#10552)
* feat: show parents on list of teams with grouping (#8635) * fix: sort teams by parent type then parent name in active teams list
1 parent 10ebdf9 commit 14dd4cf

File tree

2 files changed

+34
-17
lines changed

2 files changed

+34
-17
lines changed

ietf/group/views.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,19 @@ def active_review_dirs(request):
245245
return render(request, 'group/active_review_dirs.html', {'dirs' : dirs })
246246

247247
def active_teams(request):
248-
teams = Group.objects.filter(type="team", state="active").order_by("name")
248+
parent_type_order = {"area": 1, "adm": 3, None: 4}
249+
250+
def team_sort_key(group):
251+
type_id = group.parent.type_id if group.parent else None
252+
return (parent_type_order.get(type_id, 2), group.parent.name if group.parent else "", group.name)
253+
254+
teams = sorted(
255+
Group.objects.filter(type="team", state="active").select_related("parent"),
256+
key=team_sort_key,
257+
)
249258
for group in teams:
250259
group.chairs = sorted(roles(group, "chair"), key=extract_last_name)
251-
return render(request, 'group/active_teams.html', {'teams' : teams })
260+
return render(request, 'group/active_teams.html', {'teams': teams})
252261

253262
def active_iab(request):
254263
iabgroups = Group.objects.filter(type__in=("program","iabasg","iabworkshop"), state="active").order_by("-type_id","name")

ietf/templates/group/active_teams.html

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,29 @@ <h1>Active teams</h1>
1616
<th scope="col" data-sort="chairs">Chairs</th>
1717
</tr>
1818
</thead>
19-
<tbody>
20-
{% for group in teams %}
21-
<tr>
22-
<td>
23-
<a href="{% url "ietf.group.views.group_home" acronym=group.acronym %}">{{ group.acronym }}</a>
24-
</td>
25-
<td>{{ group.name }}</td>
26-
<td>
27-
{% for chair in group.chairs %}
28-
{% person_link chair.person %}{% if not forloop.last %},{% endif %}
29-
{% endfor %}
30-
</td>
31-
</tr>
32-
{% endfor %}
33-
</tbody>
19+
{% regroup teams by parent as grouped_teams %}
20+
{% for group_entry in grouped_teams %}
21+
<tbody>
22+
<tr class="table-info"><th scope="col" colspan="3">
23+
{% if group_entry.grouper %}{{ group_entry.grouper.name }}{% else %}Other{% endif %}
24+
</th></tr>
25+
</tbody>
26+
<tbody>
27+
{% for group in group_entry.list %}
28+
<tr>
29+
<td>
30+
<a href="{% url "ietf.group.views.group_home" acronym=group.acronym %}">{{ group.acronym }}</a>
31+
</td>
32+
<td>{{ group.name }}</td>
33+
<td>
34+
{% for chair in group.chairs %}
35+
{% person_link chair.person %}{% if not forloop.last %},{% endif %}
36+
{% endfor %}
37+
</td>
38+
</tr>
39+
{% endfor %}
40+
</tbody>
41+
{% endfor %}
3442
</table>
3543
{% endblock %}
3644
{% block js %}

0 commit comments

Comments
 (0)