Skip to content

Commit b2a858c

Browse files
fix: prevent dups in DraftAliasGenerator (ietf-tools#7650)
1 parent 20f183c commit b2a858c

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

ietf/doc/utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1389,15 +1389,17 @@ def __iter__(self) -> Iterator[tuple[str, list[str]]]:
13891389
# states__type_id, states__slug directly in the `filter()`
13901390
# works, but it does not work as expected in `exclude()`.
13911391
active_state = State.objects.get(type_id="draft", slug="active")
1392+
active_pks = [] # build a static list of the drafts we actually returned as "active"
13921393
active_drafts = drafts.filter(states=active_state)
13931394
for this_draft in active_drafts:
1395+
active_pks.append(this_draft.pk)
13941396
for alias, addresses in self._yield_aliases_for_draft(this_draft):
13951397
yield alias, addresses
13961398

13971399
# Annotate with the draft state slug so we can check for drafts that
13981400
# have become RFCs
13991401
inactive_recent_drafts = (
1400-
drafts.exclude(states=active_state)
1402+
drafts.exclude(pk__in=active_pks) # don't re-filter by state, states may have changed during the run!
14011403
.filter(expires__gte=show_since)
14021404
.annotate(
14031405
# Why _default_manager instead of objects? See:

0 commit comments

Comments
 (0)