|
38 | 38 | from django.views.decorators.cache import cache_page |
39 | 39 | from ietf.idtracker.models import IDState, IESGLogin, IDSubState, Area, InternetDraft, Rfc, IDInternal, IETFWG |
40 | 40 | from ietf.idrfc.models import RfcIndex |
| 41 | +from ietf.ipr.models import IprDraft |
41 | 42 | from django.http import Http404, HttpResponse, HttpResponseBadRequest, HttpResponsePermanentRedirect |
42 | 43 | from ietf.idrfc.idrfc_wrapper import IdWrapper,RfcWrapper,IdRfcWrapper |
43 | 44 | from ietf.utils import normalize_draftname |
@@ -579,6 +580,129 @@ def by_ad(request, name): |
579 | 580 | results.sort(key=lambda obj: obj.view_sort_key_byad()) |
580 | 581 | return render_to_response('idrfc/by_ad.html', {'form':form, 'docs':results,'meta':meta, 'ad_name':ad_name}, context_instance=RequestContext(request)) |
581 | 582 |
|
| 583 | +def ad_dashboard_group(doc): |
| 584 | + |
| 585 | + if doc.type.slug=='draft': |
| 586 | + if doc.get_state_slug('draft') == 'rfc': |
| 587 | + return 'RFC' |
| 588 | + elif doc.get_state_slug('draft') == 'active' and doc.get_state_slug('draft-iesg'): |
| 589 | + return '%s Internet-Draft' % doc.get_state('draft-iesg').name |
| 590 | + else: |
| 591 | + return '%s Internet-Draft' % doc.get_state('draft').name |
| 592 | + elif doc.type.slug=='conflrev': |
| 593 | + if doc.get_state_slug('conflrev') in ('appr-reqnopub-sent','appr-noprob-sent'): |
| 594 | + return 'Approved Conflict Review' |
| 595 | + elif doc.get_state_slug('conflrev') in ('appr-reqnopub-pend','appr-noprob-pend','appr-reqnopub-pr','appr-noprob-pr'): |
| 596 | + return "%s Conflict Review" % State.objects.get(type__slug='draft-iesg',slug='approved') |
| 597 | + else: |
| 598 | + return '%s Conflict Review' % doc.get_state('conflrev') |
| 599 | + elif doc.type.slug=='statchg': |
| 600 | + if doc.get_state_slug('statchg') in ('appr-sent',): |
| 601 | + return 'Approved Status Change' |
| 602 | + if doc.get_state_slug('statchg') in ('appr-pend','appr-pr'): |
| 603 | + return '%s Status Change' % State.objects.get(type__slug='draft-iesg',slug='approved') |
| 604 | + else: |
| 605 | + return '%s Status Change' % doc.get_state('statchg') |
| 606 | + elif doc.type.slug=='charter': |
| 607 | + if doc.get_state_slug('charter') == 'approved': |
| 608 | + return "Approved Charter" |
| 609 | + else: |
| 610 | + return '%s Charter' % doc.get_state('charter') |
| 611 | + else: |
| 612 | + return "Document" |
| 613 | + |
| 614 | +def ad_dashboard_sort_key(doc): |
| 615 | + |
| 616 | + if doc.type.slug=='draft' and doc.get_state_slug('draft') == 'rfc': |
| 617 | + return "21%04d" % int(doc.rfc_number()) |
| 618 | + if doc.type.slug=='statchg' and doc.get_state_slug('statchg') == 'appr-sent': |
| 619 | + return "22%d" % 0 # TODO - get the date of the transition into this state here |
| 620 | + if doc.type.slug=='conflrev' and doc.get_state_slug('conflrev') in ('appr-reqnopub-sent','appr-noprob-sent'): |
| 621 | + return "23%d" % 0 # TODO - get the date of the transition into this state here |
| 622 | + if doc.type.slug=='charter' and doc.get_state_slug('charter') == 'approved': |
| 623 | + return "24%d" % 0 # TODO - get the date of the transition into this state here |
| 624 | + |
| 625 | + seed = ad_dashboard_group(doc) |
| 626 | + |
| 627 | + if doc.type.slug=='conflrev' and doc.get_state_slug('conflrev') == 'adrev': |
| 628 | + state = State.objects.get(type__slug='draft-iesg',slug='ad-eval') |
| 629 | + return "1%d%s" % (state.order,seed) |
| 630 | + |
| 631 | + if doc.type.slug=='charter': |
| 632 | + if doc.get_state_slug('charter') in ('notrev','infrev'): |
| 633 | + return "100%s" % seed |
| 634 | + elif doc.get_state_slug('charter') == 'intrev': |
| 635 | + state = State.objects.get(type__slug='draft-iesg',slug='ad-eval') |
| 636 | + return "1%d%s" % (state.order,seed) |
| 637 | + elif doc.get_state_slug('charter') == 'extrev': |
| 638 | + state = State.objects.get(type__slug='draft-iesg',slug='lc') |
| 639 | + return "1%d%s" % (state.order,seed) |
| 640 | + elif doc.get_state_slug('charter') == 'iesgrev': |
| 641 | + state = State.objects.get(type__slug='draft-iesg',slug='iesg-eva') |
| 642 | + return "1%d%s" % (state.order,seed) |
| 643 | + |
| 644 | + if seed.startswith('Needs Shepherd'): |
| 645 | + return "100%s" % seed |
| 646 | + if seed.endswith(' Document'): |
| 647 | + seed = seed[:-9] |
| 648 | + elif seed.endswith(' Internet-Draft'): |
| 649 | + seed = seed[:-15] |
| 650 | + elif seed.endswith(' Conflict Review'): |
| 651 | + seed = seed[:-16] |
| 652 | + elif seed.endswith(' Status Change'): |
| 653 | + seed = seed[:-14] |
| 654 | + state = State.objects.filter(type__slug='draft-iesg',name=seed) |
| 655 | + if state: |
| 656 | + ageseconds = 0 |
| 657 | + changetime= doc.latest_event(type='changed_document') |
| 658 | + if changetime: |
| 659 | + ageseconds = (datetime.datetime.now()-doc.latest_event(type='changed_document').time).total_seconds() |
| 660 | + return "1%d%s%010d" % (state[0].order,seed,ageseconds) |
| 661 | + |
| 662 | + return "3%s" % seed |
| 663 | + |
| 664 | +def by_ad2(request, name): |
| 665 | + responsible = Document.objects.values_list('ad', flat=True).distinct() |
| 666 | + for p in Person.objects.filter(Q(role__name__in=("pre-ad", "ad"), |
| 667 | + role__group__type="area", |
| 668 | + role__group__state="active") |
| 669 | + | Q(pk__in=responsible)).distinct(): |
| 670 | + if name == p.full_name_as_key(): |
| 671 | + ad_id = p.id |
| 672 | + ad_name = p.plain_name() |
| 673 | + break |
| 674 | + docqueryset = Document.objects.filter(ad__id=ad_id) |
| 675 | + docs=[] |
| 676 | + for doc in docqueryset: |
| 677 | + doc.ad_dashboard_sort_key = ad_dashboard_sort_key(doc) |
| 678 | + doc.ad_dashboard_group = ad_dashboard_group(doc) |
| 679 | + if doc.get_state_slug() == 'rfc': |
| 680 | + doc.display_date = doc.latest_event(type='published_rfc').time |
| 681 | + else: |
| 682 | + revision = doc.latest_event(type='new_revision') |
| 683 | + if revision: |
| 684 | + doc.display_date = revision.time |
| 685 | + # This might be better handled as something Documents know about themselves |
| 686 | + now = datetime.datetime.now() |
| 687 | + 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) |
| 688 | + if doc.get_state_slug('draft') == 'rfc': |
| 689 | + 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') ] ) |
| 690 | + 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') ] ) |
| 691 | + doc.has_errata = bool(doc.tags.filter(slug="errata")) |
| 692 | + else: |
| 693 | + s = doc.get_state("draft-rfceditor") |
| 694 | + if s: |
| 695 | + # extract possible extra annotations |
| 696 | + tags = doc.tags.filter(slug__in=("iana", "ref")) |
| 697 | + doc.rfc_editor_state = "*".join([s.name] + [t.slug.upper() for t in tags]) |
| 698 | + if doc.type.slug == 'draft': |
| 699 | + doc.iprCount = IprDraft.objects.filter(document=doc, ipr__status__in=[1,3]).count() |
| 700 | + doc.iprUrl = "/ipr/search?option=document_search&id_document_tag=%s" % doc.name |
| 701 | + docs.append(doc) |
| 702 | + docs.sort(key=ad_dashboard_sort_key) |
| 703 | + return render_to_response('idrfc/by_ad2.html',{'docs':docs,'ad_name':ad_name}, context_instance=RequestContext(request)) |
| 704 | + |
| 705 | + |
582 | 706 | @cache_page(15*60) # 15 minutes |
583 | 707 | def all(request): |
584 | 708 | if settings.USE_DB_REDESIGN_PROXY_CLASSES: |
|
0 commit comments