Skip to content

Commit c7e5459

Browse files
committed
Merged in [16109] from rjsparks@nostrum.com:
Protect drafts in certain IRTF states from expiring. Fixes ietf-tools#2669. - Legacy-Id: 16129 Note: SVN reference [16109] has been migrated to Git commit 003e472
2 parents 6892a55 + 003e472 commit c7e5459

2 files changed

Lines changed: 21 additions & 6 deletions

File tree

ietf/doc/expire.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,29 @@ def expirable_draft(draft):
2121
if draft.type_id != 'draft':
2222
return False
2323
log.assertion('draft.get_state_slug("draft-iesg")')
24-
return (draft.expires and draft.get_state_slug() == "active"
25-
and draft.get_state_slug("draft-iesg") in ("idexists", "watching", "dead")
26-
and draft.get_state_slug("draft-stream-%s" % draft.stream_id) not in ("rfc-edit", "pub")
27-
and not draft.tags.filter(slug="rfc-rev"))
24+
# return (draft.expires and draft.get_state_slug() == "active"
25+
# and draft.get_state_slug("draft-iesg") in ("idexists", "watching", "dead")
26+
# and draft.get_state_slug("draft-stream-%s" % draft.stream_id) not in ("rfc-edit", "pub")
27+
# and not draft.tags.filter(slug="rfc-rev"))
28+
return bool(expirable_drafts(Document.objects.filter(pk=draft.pk)))
2829

29-
def expirable_drafts():
30+
def expirable_drafts(queryset=None):
3031
"""Return a queryset with expirable drafts."""
3132
# the general rule is that each active draft is expirable, unless
3233
# it's in a state where we shouldn't touch it
33-
d = Document.objects.filter(states__type="draft", states__slug="active").exclude(expires=None)
34+
if not queryset:
35+
queryset = Document.objects.all()
36+
37+
d = queryset.filter(states__type="draft", states__slug="active").exclude(expires=None)
3438

3539
nonexpirable_states = []
3640
# all IESG states except I-D Exists, AD Watching, and Dead block expiry
3741
nonexpirable_states += list(State.objects.filter(used=True, type="draft-iesg").exclude(slug__in=("idexists","watching", "dead")))
3842
# sent to RFC Editor and RFC Published block expiry (the latter
3943
# shouldn't be possible for an active draft, though)
4044
nonexpirable_states += list(State.objects.filter(used=True, type__in=("draft-stream-iab", "draft-stream-irtf", "draft-stream-ise"), slug__in=("rfc-edit", "pub")))
45+
# other IRTF states that block expiration
46+
nonexpirable_states += list(State.objects.filter(used=True, type_id="draft-stream-irtf", slug__in=("irsgpoll", "iesg-rev",)))
4147

4248
d = d.exclude(states__in=nonexpirable_states)
4349

ietf/doc/tests_draft.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,15 @@ def test_expire_drafts(self):
655655
self.assertTrue(not os.path.exists(os.path.join(self.id_dir, txt)))
656656
self.assertTrue(os.path.exists(os.path.join(self.archive_dir, txt)))
657657

658+
draft.delete()
659+
660+
rgdraft = RgDraftFactory(expires=datetime.datetime.now())
661+
self.assertEqual(len(list(get_expired_drafts())), 1)
662+
for slug in ('iesg-rev','irsgpoll'):
663+
rgdraft.set_state(State.objects.get(type_id='draft-stream-irtf',slug=slug))
664+
self.assertEqual(len(list(get_expired_drafts())), 0)
665+
666+
658667
def test_clean_up_draft_files(self):
659668
draft = WgDraftFactory()
660669

0 commit comments

Comments
 (0)