From 003e472d047dc06d3795f99f2db75d890e8a6da2 Mon Sep 17 00:00:00 2001 From: Robert Sparks Date: Thu, 28 Mar 2019 08:48:35 +0000 Subject: [PATCH] Protect drafts in certain IRTF states from expiring. Fixes #2669. Commit ready for merge. - Legacy-Id: 16109 --- ietf/doc/expire.py | 18 ++++++++++++------ ietf/doc/tests_draft.py | 9 +++++++++ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/ietf/doc/expire.py b/ietf/doc/expire.py index 57a128124..a99e62bb4 100644 --- a/ietf/doc/expire.py +++ b/ietf/doc/expire.py @@ -21,16 +21,20 @@ def expirable_draft(draft): if draft.type_id != 'draft': return False log.assertion('draft.get_state_slug("draft-iesg")') - return (draft.expires and draft.get_state_slug() == "active" - and draft.get_state_slug("draft-iesg") in ("idexists", "watching", "dead") - and draft.get_state_slug("draft-stream-%s" % draft.stream_id) not in ("rfc-edit", "pub") - and not draft.tags.filter(slug="rfc-rev")) + # return (draft.expires and draft.get_state_slug() == "active" + # and draft.get_state_slug("draft-iesg") in ("idexists", "watching", "dead") + # and draft.get_state_slug("draft-stream-%s" % draft.stream_id) not in ("rfc-edit", "pub") + # and not draft.tags.filter(slug="rfc-rev")) + return bool(expirable_drafts(Document.objects.filter(pk=draft.pk))) -def expirable_drafts(): +def expirable_drafts(queryset=None): """Return a queryset with expirable drafts.""" # the general rule is that each active draft is expirable, unless # it's in a state where we shouldn't touch it - d = Document.objects.filter(states__type="draft", states__slug="active").exclude(expires=None) + if not queryset: + queryset = Document.objects.all() + + d = queryset.filter(states__type="draft", states__slug="active").exclude(expires=None) nonexpirable_states = [] # all IESG states except I-D Exists, AD Watching, and Dead block expiry @@ -38,6 +42,8 @@ def expirable_drafts(): # sent to RFC Editor and RFC Published block expiry (the latter # shouldn't be possible for an active draft, though) nonexpirable_states += list(State.objects.filter(used=True, type__in=("draft-stream-iab", "draft-stream-irtf", "draft-stream-ise"), slug__in=("rfc-edit", "pub"))) + # other IRTF states that block expiration + nonexpirable_states += list(State.objects.filter(used=True, type_id="draft-stream-irtf", slug__in=("irsgpoll", "iesg-rev",))) d = d.exclude(states__in=nonexpirable_states) diff --git a/ietf/doc/tests_draft.py b/ietf/doc/tests_draft.py index 4168b1e94..13c551d1c 100644 --- a/ietf/doc/tests_draft.py +++ b/ietf/doc/tests_draft.py @@ -655,6 +655,15 @@ class ExpireIDsTests(TestCase): self.assertTrue(not os.path.exists(os.path.join(self.id_dir, txt))) self.assertTrue(os.path.exists(os.path.join(self.archive_dir, txt))) + draft.delete() + + rgdraft = RgDraftFactory(expires=datetime.datetime.now()) + self.assertEqual(len(list(get_expired_drafts())), 1) + for slug in ('iesg-rev','irsgpoll'): + rgdraft.set_state(State.objects.get(type_id='draft-stream-irtf',slug=slug)) + self.assertEqual(len(list(get_expired_drafts())), 0) + + def test_clean_up_draft_files(self): draft = WgDraftFactory()