@@ -26,31 +26,40 @@ def expirable_draft(draft):
2626 if draft .type_id != 'draft' :
2727 return False
2828 log .assertion ('draft.get_state_slug("draft-iesg")' )
29- # return (draft.expires and draft.get_state_slug() == "active"
30- # and draft.get_state_slug("draft-iesg") in ("idexists", "watching", "dead")
31- # and draft.get_state_slug("draft-stream-%s" % draft.stream_id) not in ("rfc-edit", "pub")
32- # and not draft.tags.filter(slug="rfc-rev"))
3329 return bool (expirable_drafts (Document .objects .filter (pk = draft .pk )))
3430
31+ nonexpirable_states = []
32+
3533def expirable_drafts (queryset = None ):
3634 """Return a queryset with expirable drafts."""
35+ global nonexpirable_states
36+
3737 # the general rule is that each active draft is expirable, unless
3838 # it's in a state where we shouldn't touch it
3939 if not queryset :
4040 queryset = Document .objects .all ()
4141
42- d = queryset .filter (states__type = "draft" , states__slug = "active" ).exclude (expires = None )
43-
44- nonexpirable_states = []
45- # all IESG states except I-D Exists, AD Watching, and Dead block expiry
46- nonexpirable_states += list (State .objects .filter (used = True , type = "draft-iesg" ).exclude (slug__in = ("idexists" ,"watching" , "dead" )))
47- # sent to RFC Editor and RFC Published block expiry (the latter
48- # shouldn't be possible for an active draft, though)
49- nonexpirable_states += list (State .objects .filter (used = True , type__in = ("draft-stream-iab" , "draft-stream-irtf" , "draft-stream-ise" ), slug__in = ("rfc-edit" , "pub" )))
50- # other IRTF states that block expiration
51- nonexpirable_states += list (State .objects .filter (used = True , type_id = "draft-stream-irtf" , slug__in = ("irsgpoll" , "iesg-rev" ,)))
42+ # Populate this first time through (but after django has been set up)
43+ if nonexpirable_states == []:
44+ # all IESG states except I-D Exists, AD Watching, and Dead block expiry
45+ nonexpirable_states += list (State .objects .filter (used = True , type = "draft-iesg" ).exclude (slug__in = ("idexists" ,"watching" , "dead" )))
46+ # sent to RFC Editor and RFC Published block expiry (the latter
47+ # shouldn't be possible for an active draft, though)
48+ nonexpirable_states += list (State .objects .filter (used = True , type__in = ("draft-stream-iab" , "draft-stream-irtf" , "draft-stream-ise" ), slug__in = ("rfc-edit" , "pub" )))
49+ # other IRTF states that block expiration
50+ nonexpirable_states += list (State .objects .filter (used = True , type_id = "draft-stream-irtf" , slug__in = ("irsgpoll" , "iesg-rev" ,)))
51+
52+ d = queryset .filter (states__type = "draft" , states__slug = "active" )
53+ if not d .exists ():
54+ return d
55+
56+ d = d .exclude (expires = None )
57+ if not d .exists ():
58+ return d
5259
5360 d = d .exclude (states__in = nonexpirable_states )
61+ if not d .exists ():
62+ return d
5463
5564 # under review by the RFC Editor blocks expiry
5665 d = d .exclude (tags = "rfc-rev" )
0 commit comments