Skip to content

Commit bc4752d

Browse files
authored
fix: AD order in IESG ballots (and other places) does not handle UTF-8 collation (#9836)
* Fix the ballot AD order by name * Also fix the IESG WG dashboard * Fix IESG milestones under review * Better normalization by removing completely the diacritical marks * Align comments * Test whether areas are alphabetically sorted
1 parent 2ea08c6 commit bc4752d

File tree

4 files changed

+53
-50
lines changed

4 files changed

+53
-50
lines changed

ietf/doc/views_doc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
from ietf.utils.response import permission_denied
9393
from ietf.utils.text import maybe_split
9494
from ietf.utils.timezone import date_today
95-
95+
from ietf.utils.unicodenormalize import normalize_for_sorting
9696

9797
def render_document_top(request, doc, tab, name):
9898
tabs = []
@@ -1506,7 +1506,7 @@ def document_ballot_content(request, doc, ballot_id, editable=True):
15061506
position_groups = []
15071507
for n in BallotPositionName.objects.filter(slug__in=[p.pos_id for p in positions]).order_by('order'):
15081508
g = (n, [p for p in positions if p.pos_id == n.slug])
1509-
g[1].sort(key=lambda p: (p.is_old_pos, p.balloter.plain_name()))
1509+
g[1].sort(key=lambda p: (p.is_old_pos, normalize_for_sorting(p.balloter.plain_name())))
15101510
if n.blocking:
15111511
position_groups.insert(0, g)
15121512
else:

ietf/iesg/tests.py

Lines changed: 45 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -281,12 +281,13 @@ def test_working_groups(self):
281281
wg_summary,
282282
) = get_wg_dashboard_info()
283283

284+
# checks for the expected result with area sorted by name
284285
self.assertEqual(
285286
area_summary,
286287
[
287288
{
288-
"area": "red",
289-
"groups_in_area": 1,
289+
"area": "blue",
290+
"groups_in_area": 3,
290291
"groups_with_docs": 0,
291292
"doc_count": 0,
292293
"page_count": 0,
@@ -295,8 +296,8 @@ def test_working_groups(self):
295296
"page_percent": 0,
296297
},
297298
{
298-
"area": "orange",
299-
"groups_in_area": 4,
299+
"area": "green",
300+
"groups_in_area": 3,
300301
"groups_with_docs": 0,
301302
"doc_count": 0,
302303
"page_count": 0,
@@ -305,8 +306,8 @@ def test_working_groups(self):
305306
"page_percent": 0,
306307
},
307308
{
308-
"area": "yellow",
309-
"groups_in_area": 2,
309+
"area": "orange",
310+
"groups_in_area": 4,
310311
"groups_with_docs": 0,
311312
"doc_count": 0,
312313
"page_count": 0,
@@ -315,8 +316,8 @@ def test_working_groups(self):
315316
"page_percent": 0,
316317
},
317318
{
318-
"area": "green",
319-
"groups_in_area": 3,
319+
"area": "red",
320+
"groups_in_area": 1,
320321
"groups_with_docs": 0,
321322
"doc_count": 0,
322323
"page_count": 0,
@@ -325,8 +326,8 @@ def test_working_groups(self):
325326
"page_percent": 0,
326327
},
327328
{
328-
"area": "blue",
329-
"groups_in_area": 3,
329+
"area": "violet",
330+
"groups_in_area": 4,
330331
"groups_with_docs": 0,
331332
"doc_count": 0,
332333
"page_count": 0,
@@ -335,8 +336,8 @@ def test_working_groups(self):
335336
"page_percent": 0,
336337
},
337338
{
338-
"area": "violet",
339-
"groups_in_area": 4,
339+
"area": "yellow",
340+
"groups_in_area": 2,
340341
"groups_with_docs": 0,
341342
"doc_count": 0,
342343
"page_count": 0,
@@ -1192,34 +1193,14 @@ def test_working_groups(self):
11921193
area_summary,
11931194
[
11941195
{
1195-
"area": "red",
1196-
"groups_in_area": 1,
1197-
"groups_with_docs": 1,
1198-
"doc_count": 1,
1199-
"page_count": 7,
1200-
"group_percent": 6.25,
1201-
"doc_percent": 3.571428571428571,
1202-
"page_percent": 3.5897435897435894,
1203-
},
1204-
{
1205-
"area": "orange",
1206-
"groups_in_area": 4,
1196+
"area": "blue",
1197+
"groups_in_area": 3,
12071198
"groups_with_docs": 3,
1208-
"doc_count": 4,
1209-
"page_count": 29,
1199+
"doc_count": 6,
1200+
"page_count": 40,
12101201
"group_percent": 18.75,
1211-
"doc_percent": 14.285714285714285,
1212-
"page_percent": 14.871794871794872,
1213-
},
1214-
{
1215-
"area": "yellow",
1216-
"groups_in_area": 2,
1217-
"groups_with_docs": 2,
1218-
"doc_count": 2,
1219-
"page_count": 17,
1220-
"group_percent": 12.5,
1221-
"doc_percent": 7.142857142857142,
1222-
"page_percent": 8.717948717948717,
1202+
"doc_percent": 21.428571428571427,
1203+
"page_percent": 20.51282051282051,
12231204
},
12241205
{
12251206
"area": "green",
@@ -1232,14 +1213,24 @@ def test_working_groups(self):
12321213
"page_percent": 11.282051282051283,
12331214
},
12341215
{
1235-
"area": "blue",
1236-
"groups_in_area": 3,
1216+
"area": "orange",
1217+
"groups_in_area": 4,
12371218
"groups_with_docs": 3,
1238-
"doc_count": 6,
1239-
"page_count": 40,
1219+
"doc_count": 4,
1220+
"page_count": 29,
12401221
"group_percent": 18.75,
1241-
"doc_percent": 21.428571428571427,
1242-
"page_percent": 20.51282051282051,
1222+
"doc_percent": 14.285714285714285,
1223+
"page_percent": 14.871794871794872,
1224+
},
1225+
{
1226+
"area": "red",
1227+
"groups_in_area": 1,
1228+
"groups_with_docs": 1,
1229+
"doc_count": 1,
1230+
"page_count": 7,
1231+
"group_percent": 6.25,
1232+
"doc_percent": 3.571428571428571,
1233+
"page_percent": 3.5897435897435894,
12431234
},
12441235
{
12451236
"area": "violet",
@@ -1251,6 +1242,16 @@ def test_working_groups(self):
12511242
"doc_percent": 35.714285714285715,
12521243
"page_percent": 41.02564102564102,
12531244
},
1245+
{
1246+
"area": "yellow",
1247+
"groups_in_area": 2,
1248+
"groups_with_docs": 2,
1249+
"doc_count": 2,
1250+
"page_count": 17,
1251+
"group_percent": 12.5,
1252+
"doc_percent": 7.142857142857142,
1253+
"page_percent": 8.717948717948717,
1254+
},
12541255
],
12551256
)
12561257
self.assertEqual(

ietf/iesg/utils.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from ietf.group.models import Group
1313
from ietf.iesg.agenda import get_doc_section
1414
from ietf.person.utils import get_active_ads
15-
15+
from ietf.utils.unicodenormalize import normalize_for_sorting
1616

1717
TelechatPageCount = namedtuple(
1818
"TelechatPageCount",
@@ -192,6 +192,7 @@ def get_wg_dashboard_info():
192192
else 0,
193193
}
194194
)
195+
area_summary.sort(key=lambda r: r["area"])
195196
area_totals = {
196197
"group_count": groups_total,
197198
"doc_count": docs_total,
@@ -238,7 +239,7 @@ def get_wg_dashboard_info():
238239
else 0,
239240
}
240241
)
241-
noad_summary.sort(key=lambda r: (r["ad"], r["area"]))
242+
noad_summary.sort(key=lambda r: (normalize_for_sorting(r["ad"]), r["area"]))
242243

243244
ad_summary = []
244245
ad_totals = {
@@ -278,7 +279,7 @@ def get_wg_dashboard_info():
278279
else 0,
279280
}
280281
)
281-
ad_summary.sort(key=lambda r: (r["ad"], r["area"]))
282+
ad_summary.sort(key=lambda r: (normalize_for_sorting(r["ad"]), r["area"]))
282283

283284
rfc_counter = Counter(
284285
Document.objects.filter(type="rfc").values_list("group__acronym", flat=True)

ietf/iesg/views.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
from ietf.meeting.utils import get_activity_stats
6969
from ietf.doc.utils_search import fill_in_document_table_attributes, fill_in_telechat_date
7070
from ietf.utils.timezone import date_today, datetime_from_date
71+
from ietf.utils.unicodenormalize import normalize_for_sorting
7172

7273
def review_decisions(request, year=None):
7374
events = DocEvent.objects.filter(type__in=("iesg_disapproved", "iesg_approved"))
@@ -547,7 +548,7 @@ def milestones_needing_review(request):
547548
)
548549

549550
return render(request, 'iesg/milestones_needing_review.html',
550-
dict(ads=sorted(ad_list, key=lambda ad: ad.plain_name()),))
551+
dict(ads=sorted(ad_list, key=lambda ad: normalize_for_sorting(ad.plain_name())),))
551552

552553
def photos(request):
553554
roles = sorted(Role.objects.filter(group__type='area', group__state='active', name_id='ad'),key=lambda x: "" if x.group.acronym=="gen" else x.group.acronym)

0 commit comments

Comments
 (0)