From 56ac85346225db5e62930607f50fd9089e7c30a1 Mon Sep 17 00:00:00 2001 From: Jennifer Richards Date: Wed, 31 Jul 2024 10:44:55 -0300 Subject: [PATCH 1/3] fix: use BOF states in concluded_groups() --- ietf/group/views.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ietf/group/views.py b/ietf/group/views.py index f909a31b6d..1991e33550 100644 --- a/ietf/group/views.py +++ b/ietf/group/views.py @@ -355,10 +355,16 @@ def concluded_groups(request): for g in groups: g.start_date = g.conclude_date = None - for e in ChangeStateGroupEvent.objects.filter(group__in=groups, state="active").order_by("-time"): + for e in ChangeStateGroupEvent.objects.filter( + group__in=groups, + state="bof" if name == "BOFs" else "active", + ).order_by("-time"): d[e.group_id].start_date = e.time - for e in ChangeStateGroupEvent.objects.filter(group__in=groups, state="conclude").order_by("time"): + for e in ChangeStateGroupEvent.objects.filter( + group__in=groups, + state="bof-conc" if name == "BOFs" else "conclude", + ).order_by("time"): d[e.group_id].conclude_date = e.time return render(request, 'group/concluded_groups.html', From 793df47ac25c1524bd53cf9f99b501306a6fbac1 Mon Sep 17 00:00:00 2001 From: Jennifer Richards Date: Wed, 31 Jul 2024 11:10:47 -0300 Subject: [PATCH 2/3] fix: handle events for older BOFs These could be cleaned up in the database, but I think this change does the right thing for the existing data. --- ietf/group/views.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/ietf/group/views.py b/ietf/group/views.py index 1991e33550..b5faa0cbf1 100644 --- a/ietf/group/views.py +++ b/ietf/group/views.py @@ -355,15 +355,24 @@ def concluded_groups(request): for g in groups: g.start_date = g.conclude_date = None + # Some older BOFs were created in the "active" state, so consider both "active" and "bof" + # ChangeStateGroupEvents when finding the start date. A group with _both_ "active" and "bof" + # events should not be in the "bof-conc" state so this shouldn't cause a problem (if it does, + # we'll need to clean up the data) for e in ChangeStateGroupEvent.objects.filter( group__in=groups, - state="bof" if name == "BOFs" else "active", + state__in=["active", "bof"] if name == "BOFs" else ["active"], ).order_by("-time"): d[e.group_id].start_date = e.time + # Similarly, some older BOFs were concluded into the "conclude" state and the event was never + # fixed, so consider both "conclude" and "bof-conc" ChangeStateGroupEvents when finding the + # concluded date. A group with _both_ "conclude" and "bof-conc" events should not be in the + # "bof-conc" state so this shouldn't cause a problem (if it does, we'll need to clean up the + # data) for e in ChangeStateGroupEvent.objects.filter( group__in=groups, - state="bof-conc" if name == "BOFs" else "conclude", + state__in=["bof-conc", "conclude"] if name == "BOFs" else ["conclude"], ).order_by("time"): d[e.group_id].conclude_date = e.time From 921a928549e1f89f443050746f5da963db72dc92 Mon Sep 17 00:00:00 2001 From: Jennifer Richards Date: Wed, 31 Jul 2024 11:14:47 -0300 Subject: [PATCH 3/3] style: Black --- ietf/group/views.py | 62 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 49 insertions(+), 13 deletions(-) diff --git a/ietf/group/views.py b/ietf/group/views.py index b5faa0cbf1..e3fd7e80d9 100644 --- a/ietf/group/views.py +++ b/ietf/group/views.py @@ -334,21 +334,57 @@ def chartering_groups(request): dict(charter_states=charter_states, group_types=group_types)) + def concluded_groups(request): sections = OrderedDict() - sections['WGs'] = Group.objects.filter(type='wg', state="conclude").select_related("state", "charter").order_by("parent__name","acronym") - sections['RGs'] = Group.objects.filter(type='rg', state="conclude").select_related("state", "charter").order_by("parent__name","acronym") - sections['BOFs'] = Group.objects.filter(type='wg', state="bof-conc").select_related("state", "charter").order_by("parent__name","acronym") - sections['AGs'] = Group.objects.filter(type='ag', state="conclude").select_related("state", "charter").order_by("parent__name","acronym") - sections['RAGs'] = Group.objects.filter(type='rag', state="conclude").select_related("state", "charter").order_by("parent__name","acronym") - sections['Directorates'] = Group.objects.filter(type='dir', state="conclude").select_related("state", "charter").order_by("parent__name","acronym") - sections['Review teams'] = Group.objects.filter(type='review', state="conclude").select_related("state", "charter").order_by("parent__name","acronym") - sections['Teams'] = Group.objects.filter(type='team', state="conclude").select_related("state", "charter").order_by("parent__name","acronym") - sections['Programs'] = Group.objects.filter(type='program', state="conclude").select_related("state", "charter").order_by("parent__name","acronym") + sections["WGs"] = ( + Group.objects.filter(type="wg", state="conclude") + .select_related("state", "charter") + .order_by("parent__name", "acronym") + ) + sections["RGs"] = ( + Group.objects.filter(type="rg", state="conclude") + .select_related("state", "charter") + .order_by("parent__name", "acronym") + ) + sections["BOFs"] = ( + Group.objects.filter(type="wg", state="bof-conc") + .select_related("state", "charter") + .order_by("parent__name", "acronym") + ) + sections["AGs"] = ( + Group.objects.filter(type="ag", state="conclude") + .select_related("state", "charter") + .order_by("parent__name", "acronym") + ) + sections["RAGs"] = ( + Group.objects.filter(type="rag", state="conclude") + .select_related("state", "charter") + .order_by("parent__name", "acronym") + ) + sections["Directorates"] = ( + Group.objects.filter(type="dir", state="conclude") + .select_related("state", "charter") + .order_by("parent__name", "acronym") + ) + sections["Review teams"] = ( + Group.objects.filter(type="review", state="conclude") + .select_related("state", "charter") + .order_by("parent__name", "acronym") + ) + sections["Teams"] = ( + Group.objects.filter(type="team", state="conclude") + .select_related("state", "charter") + .order_by("parent__name", "acronym") + ) + sections["Programs"] = ( + Group.objects.filter(type="program", state="conclude") + .select_related("state", "charter") + .order_by("parent__name", "acronym") + ) for name, groups in sections.items(): - # add start/conclusion date d = dict((g.pk, g) for g in groups) @@ -360,7 +396,7 @@ def concluded_groups(request): # events should not be in the "bof-conc" state so this shouldn't cause a problem (if it does, # we'll need to clean up the data) for e in ChangeStateGroupEvent.objects.filter( - group__in=groups, + group__in=groups, state__in=["active", "bof"] if name == "BOFs" else ["active"], ).order_by("-time"): d[e.group_id].start_date = e.time @@ -376,8 +412,8 @@ def concluded_groups(request): ).order_by("time"): d[e.group_id].conclude_date = e.time - return render(request, 'group/concluded_groups.html', - dict(sections=sections)) + return render(request, "group/concluded_groups.html", dict(sections=sections)) + def prepare_group_documents(request, group, clist): found_docs, meta = prepare_document_table(request, docs_tracked_by_community_list(clist), request.GET, max_results=500)