|
43 | 43 | from django.shortcuts import render_to_response, get_object_or_404 |
44 | 44 | from django.conf import settings |
45 | 45 | from django.utils import simplejson as json |
| 46 | +from django.db import models |
46 | 47 | from django import forms |
47 | 48 |
|
48 | | -from ietf.idtracker.models import IDInternal, InternetDraft, AreaGroup, Position, IESGLogin, Acronym |
49 | | -from ietf.idrfc.idrfc_wrapper import IdWrapper, RfcWrapper |
50 | | - |
51 | 49 | from ietf.iesg.models import TelechatDate, TelechatAgendaItem |
52 | 50 | from ietf.ipr.models import IprDocAlias |
53 | | -from ietf.doc.models import Document, TelechatDocEvent, LastCallDocEvent, ConsensusDocEvent, DocEvent |
| 51 | +from ietf.doc.models import Document, TelechatDocEvent, LastCallDocEvent, ConsensusDocEvent, DocEvent, IESG_BALLOT_ACTIVE_STATES |
54 | 52 | from ietf.group.models import Group, GroupMilestone |
55 | 53 | from ietf.person.models import Person |
56 | 54 |
|
57 | | -from ietf.doc.utils import update_telechat |
58 | | -from ietf.ietfauth.utils import has_role, role_required |
| 55 | +from ietf.doc.utils import update_telechat, augment_events_with_revision |
| 56 | +from ietf.ietfauth.utils import has_role, role_required, user_is_person |
59 | 57 | from ietf.iesg.agenda import * |
60 | 58 |
|
61 | 59 | def review_decisions(request, year=None): |
@@ -387,31 +385,39 @@ def telechat_docs_tarfile(request, date): |
387 | 385 | return response |
388 | 386 |
|
389 | 387 | def discusses(request): |
390 | | - res = [] |
| 388 | + possible_docs = Document.objects.filter(models.Q(states__type="draft-iesg", |
| 389 | + states__slug__in=IESG_BALLOT_ACTIVE_STATES) | |
| 390 | + models.Q(states__type="charter", |
| 391 | + states__slug__in=("intrev", "iesgrev")) | |
| 392 | + models.Q(states__type__in=("statchg", "conflrev"), |
| 393 | + states__slug__in=("iesgeval", "defer")), |
| 394 | + docevent__ballotpositiondocevent__pos__blocking=True) |
| 395 | + possible_docs = possible_docs.select_related("stream", "group", "ad").distinct()[:10] |
| 396 | + |
| 397 | + docs = [] |
| 398 | + for doc in possible_docs: |
| 399 | + ballot = doc.active_ballot() |
| 400 | + if not ballot: |
| 401 | + continue |
391 | 402 |
|
392 | | - for d in IDInternal.objects.filter(states__type="draft-iesg", states__slug__in=("pub-req", "ad-eval", "review-e", "lc-req", "lc", "writeupw", "goaheadw", "iesg-eva", "defer", "watching"), docevent__ballotpositiondocevent__pos="discuss").distinct(): |
393 | | - found = False |
394 | | - for p in d.positions.all(): |
395 | | - if p.discuss: |
396 | | - found = True |
397 | | - break |
| 403 | + blocking_positions = [p for p in ballot.all_positions() if p.pos.blocking] |
398 | 404 |
|
399 | | - if not found: |
| 405 | + if not blocking_positions: |
400 | 406 | continue |
401 | 407 |
|
402 | | - if d.rfc_flag: |
403 | | - doc = RfcWrapper(d) |
404 | | - else: |
405 | | - doc = IdWrapper(draft=d) |
| 408 | + augment_events_with_revision(doc, blocking_positions) |
| 409 | + |
| 410 | + doc.by_me = bool([p for p in blocking_positions if user_is_person(request.user, p.ad)]) |
| 411 | + doc.for_me = user_is_person(request.user, doc.ad) |
| 412 | + doc.milestones = doc.groupmilestone_set.filter(state="active").order_by("time").select_related("group") |
| 413 | + doc.blocking_positions = blocking_positions |
406 | 414 |
|
407 | | - if doc.in_ietf_process() and doc.ietf_process.has_active_iesg_ballot(): |
408 | | - # quick hack - to be removed when the proxy code is removed |
409 | | - doc.underlying = doc.underlying_document() |
410 | | - doc.underlying.milestones = d.groupmilestone_set.filter(state="active").order_by("time").select_related("group") |
| 415 | + docs.append(doc) |
411 | 416 |
|
412 | | - res.append(doc) |
| 417 | + # latest first |
| 418 | + docs.sort(key=lambda d: min(p.time for p in d.blocking_positions), reverse=True) |
413 | 419 |
|
414 | | - return direct_to_template(request, 'iesg/discusses.html', {'docs':res}) |
| 420 | + return direct_to_template(request, 'iesg/discusses.html', { 'docs': docs }) |
415 | 421 |
|
416 | 422 | @role_required('Area Director', 'Secretariat') |
417 | 423 | def milestones_needing_review(request): |
|
0 commit comments