4747from ietf .doc .utils import *
4848from ietf .utils .history import find_history_active_at
4949from ietf .ietfauth .utils import *
50+ from ietf .doc .views_status_change import RELATION_SLUGS as status_change_relationships
51+ from ietf .wgcharter .utils import historic_milestones_for_charter
5052
5153def render_document_top (request , doc , tab , name ):
5254 tabs = []
5355 tabs .append (("Document" , "document" , urlreverse ("doc_view" , kwargs = dict (name = name )), True ))
5456
5557 ballot = doc .latest_event (BallotDocEvent , type = "created_ballot" )
56- if doc .type_id in ("draft" ,"conflrev" ):
58+ if doc .type_id in ("draft" ,"conflrev" , "statchg" ):
5759 # if doc.in_ietf_process and doc.ietf_process.has_iesg_ballot:
5860 tabs .append (("IESG Evaluation Record" , "ballot" , urlreverse ("doc_ballot" , kwargs = dict (name = name )), ballot ))
5961 elif doc .type_id == "charter" :
6062 tabs .append (("IESG Review" , "ballot" , urlreverse ("doc_ballot" , kwargs = dict (name = name )), ballot ))
6163
6264 # FIXME: if doc.in_ietf_process and doc.ietf_process.has_iesg_ballot:
63- if doc .type_id != "conflrev" :
65+ if doc .type_id not in [ "conflrev" , "statchg" ] :
6466 tabs .append (("IESG Writeups" , "writeup" , urlreverse ("doc_writeup" , kwargs = dict (name = name )), True ))
6567
6668 tabs .append (("History" , "history" , urlreverse ("doc_history" , kwargs = dict (name = name )), True ))
@@ -227,7 +229,9 @@ def document_main(request, name, rev=None):
227229
228230 # submission
229231 submission = ""
230- if group .type_id == "individ" :
232+ if group is None :
233+ submission = "unknown"
234+ elif group .type_id == "individ" :
231235 submission = "individual"
232236 elif group .type_id == "area" and doc .stream_id == "ietf" :
233237 submission = "individual in %s area" % group .acronym
@@ -271,6 +275,10 @@ def document_main(request, name, rev=None):
271275 # conflict reviews
272276 conflict_reviews = [d .name for d in doc .related_that ("conflrev" )]
273277
278+ status_change_docs = doc .related_that (status_change_relationships )
279+ status_changes = [ rel for rel in status_change_docs if rel .get_state_slug () in ('appr-sent' ,'appr-pend' )]
280+ proposed_status_changes = [ rel for rel in status_change_docs if rel .get_state_slug () in ('needshep' ,'adrev' ,'iesgeval' ,'defer' ,'appr-pr' )]
281+
274282 # remaining actions
275283 actions = []
276284
@@ -329,6 +337,8 @@ def document_main(request, name, rev=None):
329337 obsoletes = [prettify_std_name (d .name ) for d in doc .related_that_doc ("obs" )],
330338 obsoleted_by = [prettify_std_name (d .canonical_name ()) for d in doc .related_that ("obs" )],
331339 conflict_reviews = conflict_reviews ,
340+ status_changes = status_changes ,
341+ proposed_status_changes = proposed_status_changes ,
332342 rfc_aliases = rfc_aliases ,
333343 has_errata = doc .tags .filter (slug = "errata" ),
334344 published = doc .latest_event (type = "published_rfc" ),
@@ -410,6 +420,40 @@ def document_main(request, name, rev=None):
410420 ),
411421 context_instance = RequestContext (request ))
412422
423+ if doc .type_id == "statchg" :
424+ filename = "%s-%s.txt" % (doc .canonical_name (), doc .rev )
425+ pathname = os .path .join (settings .STATUS_CHANGE_PATH ,filename )
426+
427+ if doc .rev == "00" and not os .path .isfile (pathname ):
428+ # This could move to a template
429+ content = "Status change text has not yet been proposed."
430+ else :
431+ content = get_document_content (filename , pathname , split = False )
432+
433+ ballot_summary = None
434+ if doc .get_state_slug () in ("iesgeval" ):
435+ ballot_summary = needed_ballot_positions (doc , doc .active_ballot ().active_ad_positions ().values ())
436+
437+ if isinstance (doc ,Document ):
438+ sorted_relations = doc .relateddocument_set .all ().order_by ('relationship__name' )
439+ elif isinstance (doc ,DocHistory ):
440+ sorted_relations = doc .relateddochistory_set .all ().order_by ('relationship__name' )
441+ else :
442+ sorted_relations = None
443+
444+ return render_to_response ("idrfc/document_status_change.html" ,
445+ dict (doc = doc ,
446+ top = top ,
447+ content = content ,
448+ revisions = revisions ,
449+ snapshot = snapshot ,
450+ telechat = telechat ,
451+ ballot_summary = ballot_summary ,
452+ approved_states = ('appr-pend' ,'appr-sent' ),
453+ sorted_relations = sorted_relations ,
454+ ),
455+ context_instance = RequestContext (request ))
456+
413457 raise Http404
414458
415459
@@ -420,7 +464,7 @@ def document_history(request, name):
420464 # pick up revisions from events
421465 diff_revisions = []
422466
423- diffable = name .startswith ("draft" ) or name .startswith ("charter" ) or name .startswith ("conflict-review" )
467+ diffable = name .startswith ("draft" ) or name .startswith ("charter" ) or name .startswith ("conflict-review" ) or name . startswith ( "status-change" )
424468 if diffable :
425469 diff_documents = [ doc ]
426470 diff_documents .extend (Document .objects .filter (docalias__relateddocument__source = doc , docalias__relateddocument__relationship = "replaces" ))
@@ -438,6 +482,9 @@ def document_history(request, name):
438482 elif name .startswith ("conflict-review" ):
439483 h = find_history_active_at (e .doc , e .time )
440484 url = settings .CONFLICT_REVIEW_TXT_URL + ("%s-%s.txt" % ((h or doc ).canonical_name (), e .rev ))
485+ elif name .startswith ("status-change" ):
486+ h = find_history_active_at (e .doc , e .time )
487+ url = settings .STATUS_CHANGE_TXT_URL + ("%s-%s.txt" % ((h or doc ).canonical_name (), e .rev ))
441488 elif name .startswith ("draft" ):
442489 # rfcdiff tool has special support for IDs
443490 url = e .doc .name + "-" + e .rev
0 commit comments