Protect drafts in certain IRTF states from expiring. Fixes #2669. Commit ready for merge.

- Legacy-Id: 16109
This commit is contained in:
Robert Sparks 2019-03-28 08:48:35 +00:00
parent 69acaccf14
commit 003e472d04
2 changed files with 21 additions and 6 deletions

View file

@ -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)

View file

@ -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()