@@ -372,6 +372,136 @@ def drafts_for_ad(request, name):
372372 { 'form' :form , 'docs' :results , 'meta' :meta , 'ad_name' : ad .plain_name () },
373373 context_instance = RequestContext (request ))
374374
375+ def ad_dashboard_group (doc ):
376+
377+ if doc .type .slug == 'draft' :
378+ if doc .get_state_slug ('draft' ) == 'rfc' :
379+ return 'RFC'
380+ elif doc .get_state_slug ('draft' ) == 'active' and doc .get_state_slug ('draft-iesg' ):
381+ return '%s Internet-Draft' % doc .get_state ('draft-iesg' ).name
382+ else :
383+ return '%s Internet-Draft' % doc .get_state ('draft' ).name
384+ elif doc .type .slug == 'conflrev' :
385+ if doc .get_state_slug ('conflrev' ) in ('appr-reqnopub-sent' ,'appr-noprob-sent' ):
386+ return 'Approved Conflict Review'
387+ elif doc .get_state_slug ('conflrev' ) in ('appr-reqnopub-pend' ,'appr-noprob-pend' ,'appr-reqnopub-pr' ,'appr-noprob-pr' ):
388+ return "%s Conflict Review" % State .objects .get (type__slug = 'draft-iesg' ,slug = 'approved' )
389+ else :
390+ return '%s Conflict Review' % doc .get_state ('conflrev' )
391+ elif doc .type .slug == 'statchg' :
392+ if doc .get_state_slug ('statchg' ) in ('appr-sent' ,):
393+ return 'Approved Status Change'
394+ if doc .get_state_slug ('statchg' ) in ('appr-pend' ,'appr-pr' ):
395+ return '%s Status Change' % State .objects .get (type__slug = 'draft-iesg' ,slug = 'approved' )
396+ else :
397+ return '%s Status Change' % doc .get_state ('statchg' )
398+ elif doc .type .slug == 'charter' :
399+ if doc .get_state_slug ('charter' ) == 'approved' :
400+ return "Approved Charter"
401+ else :
402+ return '%s Charter' % doc .get_state ('charter' )
403+ else :
404+ return "Document"
405+
406+ def ad_dashboard_sort_key (doc ):
407+
408+ if doc .type .slug == 'draft' and doc .get_state_slug ('draft' ) == 'rfc' :
409+ return "21%04d" % int (doc .rfc_number ())
410+ if doc .type .slug == 'statchg' and doc .get_state_slug ('statchg' ) == 'appr-sent' :
411+ return "22%d" % 0 # TODO - get the date of the transition into this state here
412+ if doc .type .slug == 'conflrev' and doc .get_state_slug ('conflrev' ) in ('appr-reqnopub-sent' ,'appr-noprob-sent' ):
413+ return "23%d" % 0 # TODO - get the date of the transition into this state here
414+ if doc .type .slug == 'charter' and doc .get_state_slug ('charter' ) == 'approved' :
415+ return "24%d" % 0 # TODO - get the date of the transition into this state here
416+
417+ seed = ad_dashboard_group (doc )
418+
419+ if doc .type .slug == 'conflrev' and doc .get_state_slug ('conflrev' ) == 'adrev' :
420+ state = State .objects .get (type__slug = 'draft-iesg' ,slug = 'ad-eval' )
421+ return "1%d%s" % (state .order ,seed )
422+
423+ if doc .type .slug == 'charter' :
424+ if doc .get_state_slug ('charter' ) in ('notrev' ,'infrev' ):
425+ return "100%s" % seed
426+ elif doc .get_state_slug ('charter' ) == 'intrev' :
427+ state = State .objects .get (type__slug = 'draft-iesg' ,slug = 'ad-eval' )
428+ return "1%d%s" % (state .order ,seed )
429+ elif doc .get_state_slug ('charter' ) == 'extrev' :
430+ state = State .objects .get (type__slug = 'draft-iesg' ,slug = 'lc' )
431+ return "1%d%s" % (state .order ,seed )
432+ elif doc .get_state_slug ('charter' ) == 'iesgrev' :
433+ state = State .objects .get (type__slug = 'draft-iesg' ,slug = 'iesg-eva' )
434+ return "1%d%s" % (state .order ,seed )
435+
436+ if doc .type .slug == 'statchg' and doc .get_state_slug ('statchg' ) == 'adrev' :
437+ state = State .objects .get (type__slug = 'draft-iesg' ,slug = 'ad-eval' )
438+ return "1%d%s" % (state .order ,seed )
439+
440+ if seed .startswith ('Needs Shepherd' ):
441+ return "100%s" % seed
442+ if seed .endswith (' Document' ):
443+ seed = seed [:- 9 ]
444+ elif seed .endswith (' Internet-Draft' ):
445+ seed = seed [:- 15 ]
446+ elif seed .endswith (' Conflict Review' ):
447+ seed = seed [:- 16 ]
448+ elif seed .endswith (' Status Change' ):
449+ seed = seed [:- 14 ]
450+ state = State .objects .filter (type__slug = 'draft-iesg' ,name = seed )
451+ if state :
452+ ageseconds = 0
453+ changetime = doc .latest_event (type = 'changed_document' )
454+ if changetime :
455+ ad = (datetime .datetime .now ()- doc .latest_event (type = 'changed_document' ).time )
456+ ageseconds = (ad .microseconds + (ad .seconds + ad .days * 24 * 3600 ) * 10 ** 6 ) / 10 ** 6
457+ return "1%d%s%s%010d" % (state [0 ].order ,seed ,doc .type .slug ,ageseconds )
458+
459+ return "3%s" % seed
460+
461+ def docs_for_ad (request , name ):
462+ ad = None
463+ responsible = Document .objects .values_list ('ad' , flat = True ).distinct ()
464+ for p in Person .objects .filter (Q (role__name__in = ("pre-ad" , "ad" ),
465+ role__group__type = "area" ,
466+ role__group__state = "active" )
467+ | Q (pk__in = responsible )).distinct ():
468+ if name == p .full_name_as_key ():
469+ ad = p
470+ break
471+ if not ad :
472+ raise Http404
473+
474+ docqueryset = Document .objects .filter (ad__id = ad .id )
475+ docs = []
476+ for doc in docqueryset :
477+ doc .ad_dashboard_sort_key = ad_dashboard_sort_key (doc )
478+ doc .ad_dashboard_group = ad_dashboard_group (doc )
479+ if doc .get_state_slug () == 'rfc' :
480+ doc .display_date = doc .latest_event (type = 'published_rfc' ).time
481+ else :
482+ revision = doc .latest_event (type = 'new_revision' )
483+ if revision :
484+ doc .display_date = revision .time
485+ # This might be better handled as something Documents know about themselves
486+ now = datetime .datetime .now ()
487+ doc .can_expire = (doc .type .slug == 'draft' and doc .get_state_slug ('draft' )== 'active' and ( not doc .get_state ('draft-iesg' ) or doc .get_state ('draft-iesg' ).order >= 42 ) and doc .expires > now )
488+ if doc .get_state_slug ('draft' ) == 'rfc' :
489+ doc .obsoleted_by = ", " .join ([ 'RFC %04d' % int (rel .source .rfc_number ()) for alias in doc .docalias_set .all () for rel in alias .relateddocument_set .filter (relationship = 'obsoletes' ) ] )
490+ doc .updated_by = ", " .join ([ 'RFC %04d' % int (rel .source .rfc_number ()) for alias in doc .docalias_set .all () for rel in alias .relateddocument_set .filter (relationship = 'updates' ) ] )
491+ doc .has_errata = bool (doc .tags .filter (slug = "errata" ))
492+ else :
493+ s = doc .get_state ("draft-rfceditor" )
494+ if s :
495+ # extract possible extra annotations
496+ tags = doc .tags .filter (slug__in = ("iana" , "ref" ))
497+ doc .rfc_editor_state = "*" .join ([s .name ] + [t .slug .upper () for t in tags ])
498+ if doc .type .slug == 'draft' :
499+ doc .iprCount = IprDocAlias .objects .filter (doc_alias__document = doc , ipr__status__in = [1 ,3 ]).count ()
500+ doc .iprUrl = "/ipr/search?option=document_search&id_document_tag=%s" % doc .name
501+ docs .append (doc )
502+ docs .sort (key = ad_dashboard_sort_key )
503+ return render_to_response ('doc/by_ad2.html' ,{'docs' :docs ,'ad_name' :ad .plain_name ()}, context_instance = RequestContext (request ))
504+
375505def drafts_in_last_call (request ):
376506 lc_state = State .objects .get (type = "draft-iesg" , slug = "lc" ).pk
377507 form = SearchForm ({'by' :'state' ,'state' : lc_state , 'rfcs' :'on' , 'activedrafts' :'on' })
0 commit comments