Skip to content

Commit 1975ff2

Browse files
committed
Port IESG discusses to new schema
- Legacy-Id: 6418
1 parent d11f233 commit 1975ff2

3 files changed

Lines changed: 94 additions & 87 deletions

File tree

ietf/iesg/views.py

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,17 @@
4343
from django.shortcuts import render_to_response, get_object_or_404
4444
from django.conf import settings
4545
from django.utils import simplejson as json
46+
from django.db import models
4647
from django import forms
4748

48-
from ietf.idtracker.models import IDInternal, InternetDraft, AreaGroup, Position, IESGLogin, Acronym
49-
from ietf.idrfc.idrfc_wrapper import IdWrapper, RfcWrapper
50-
5149
from ietf.iesg.models import TelechatDate, TelechatAgendaItem
5250
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
5452
from ietf.group.models import Group, GroupMilestone
5553
from ietf.person.models import Person
5654

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
5957
from ietf.iesg.agenda import *
6058

6159
def review_decisions(request, year=None):
@@ -387,31 +385,39 @@ def telechat_docs_tarfile(request, date):
387385
return response
388386

389387
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
391402

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]
398404

399-
if not found:
405+
if not blocking_positions:
400406
continue
401407

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
406414

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)
411416

412-
res.append(doc)
417+
# latest first
418+
docs.sort(key=lambda d: min(p.time for p in d.blocking_positions), reverse=True)
413419

414-
return direct_to_template(request, 'iesg/discusses.html', {'docs':res})
420+
return direct_to_template(request, 'iesg/discusses.html', { 'docs': docs })
415421

416422
@role_required('Area Director', 'Secretariat')
417423
def milestones_needing_review(request):

ietf/templates/iesg/discusses.html

Lines changed: 31 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -39,81 +39,49 @@
3939
{% block title %}IESG Discuss Positions{% endblock %}
4040

4141
{% block morecss %}
42-
.discuss_hidden {display:none;}
42+
.discusses-chooser label { display: inline-block; margin-right: 0.5em; }
43+
.discusses-chooser input { vertical-align: middle; margin: 0; padding: 0; margin-right: 0.3em; }
4344
{% endblock %}
4445

4546
{% block content %}
4647
<h1>IESG Discuss Positions</h1>
4748

48-
{% if user|in_group:"Area_Director" %}
49-
<div style="padding:4px 0;">
50-
Show: <input type="radio" name="discuss_show" checked="checked" value="all" id="discusses_all" onclick="radio_changed();"/>All
51-
<input type="radio" name="discuss_show" value="byme" id="discusses_byme" onclick="radio_changed();"/>By me
52-
<input type="radio" name="discuss_show" value="forme" id="discusses_forme" onclick="radio_changed();"/>For me
53-
</div>
49+
{% if user|has_role:"Area Director" %}
50+
<p class="discusses-chooser">
51+
Show:
52+
<label><input type="radio" name="discusses" checked="checked" value="all"/>All</label>
53+
<label><input type="radio" name="discusses" value="byme"/>By me</label>
54+
<label><input type="radio" name="discusses" value="forme"/>For me</label>
55+
</p>
5456
{% endif %}
5557

5658
<table class="ietf-table ietf-doctable">
57-
<tr><th class="doc">Document</th><th class="status" colspan="2">Status</th><th class="ad">Area Director</th><th>Discusses</th></tr>
58-
{% for doc in docs %}
59-
<tr class="discuss_row {% cycle oddrow,evenrow %} {% if user|in_group:"Area_Director" %}{% if doc|my_position:user|equal:"Discuss" %}discuss_byme{% else %}discuss_notbyme{% endif %} {% ifequal user.get_profile.person|lower doc.ad_name|lower %}discuss_forme{%else%}discuss_notforme{%endifequal%}{% endif %}">
60-
<td class="doc">{{ doc.displayname_with_link|safe }}</td>
61-
{% with doc.underlying as doc %}{% include "doc/search/status_columns.html" %}{% endwith %}
62-
<td class="ad">{{ doc.ad_name|default:"" }}</td>
63-
<td>
64-
{% for po in doc.ietf_process.iesg_ballot.get_discuss|dictsort:"is_old_ad" %}
65-
{%if po.is_old_ad %}[{%endif%}{{po.ad_name}}{%if po.is_old_ad %}]{%endif%} ({% if po.discuss_date %}{{po.discuss_date|timesince_days}}{%endif%} days ago{% if doc.is_id_wrapper %}{% ifnotequal po.discuss_revision doc.latest_revision %} for -{{po.discuss_revision}}{% endifnotequal %}{% endif %})<br/>
66-
{% endfor %}
67-
</td>
68-
</tr>
69-
{% endfor %}
59+
<tr>
60+
<th class="doc">Document</th>
61+
<th class="status" colspan="2">Status</th>
62+
<th class="ad">Area Director</th>
63+
<th>Discusses</th>
64+
</tr>
65+
66+
{% for doc in docs %}
67+
<tr class="discuss-row {{ forloop.counter|divisibleby:2|yesno:"evenrow,oddrow" }} {% if doc.by_me %}byme{% endif %} {% if doc.for_me %}forme{% endif %}">
68+
<td class="doc">{{ doc.displayname_with_link }}</td>
69+
70+
{% include "doc/search/status_columns.html" %}
71+
72+
<td class="ad">{{ doc.ad|default:"" }}</td>
73+
<td>
74+
{% for p in doc.blocking_positions %}
75+
{% if p.old_ad %}[{% endif %}{{ p.ad }}{% if p.old_ad %}]{% endif %} ({% if p.discuss_time %}{{ p.discuss_time|timesince_days }}{% endif %} days ago{% if doc.get_state_url != "rfc" and p.rev != doc.rev %} for -{{ p.rev }}{% endif %})<br/>
76+
{% endfor %}
77+
</td>
78+
</tr>
79+
{% endfor %}
7080
</table>
7181
{% endblock content %}
7282

73-
{% block scripts %}
74-
{% if user|in_group:"Area_Director" %}
75-
function update_even_odd() {
76-
var els = YAHOO.util.Dom.getElementsByClassName("discuss_row","tr");
77-
var j = 1;
78-
for (var i = 0; i < els.length; i++) {
79-
if (!YAHOO.util.Dom.hasClass(els[i], "discuss_hidden")) {
80-
if ((j % 2) == 1) {
81-
YAHOO.util.Dom.replaceClass(els[i], "evenrow", "oddrow");
82-
} else {
83-
YAHOO.util.Dom.replaceClass(els[i], "oddrow", "evenrow");
84-
}
85-
j++;
86-
}
87-
}
88-
}
89-
function radio_changed() {
90-
var els1 = YAHOO.util.Dom.getElementsByClassName("discuss_notbyme","tr");
91-
YAHOO.util.Dom.removeClass(els1, "discuss_hidden");
92-
var els2 = YAHOO.util.Dom.getElementsByClassName("discuss_notforme","tr");
93-
YAHOO.util.Dom.removeClass(els2, "discuss_hidden");
94-
if (document.getElementById("discusses_byme").checked) {
95-
YAHOO.util.Dom.addClass(els1, "discuss_hidden");
96-
location.hash = "#byme";
97-
} else if (document.getElementById("discusses_forme").checked) {
98-
YAHOO.util.Dom.addClass(els2, "discuss_hidden");
99-
location.hash = "#forme";
100-
} else {
101-
location.hash = "#";
102-
}
103-
update_even_odd();
104-
}
105-
var url = location.href.split('#');
106-
if (url[1] == 'byme') {
107-
document.getElementById("discusses_byme").checked = true;
108-
radio_changed();
109-
} else if (url[1] == 'forme') {
110-
document.getElementById("discusses_forme").checked = true;
111-
radio_changed();
112-
}
113-
{% endif %}{# user in_group #}
114-
{% endblock scripts %}
115-
11683
{% block js %}
11784
<script type="text/javascript" src="/js/utils.js"></script>
11885
<script type="text/javascript" src="/js/doc-search.js"></script>
86+
<script type="text/javascript" src="/js/iesg-discusses.js"></script>
11987
{% endblock %}

static/js/iesg-discusses.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
jQuery(function () {
2+
var radioButtons = jQuery('input[name="discusses"]');
3+
4+
var url = window.location.hash.replace("#", "");
5+
if (url == "byme" || url == "forme")
6+
radioButtons.filter("[value=" + url + "]").click();
7+
8+
function updateDisplayedRows() {
9+
var rows = jQuery(".discuss-row");
10+
11+
var val = radioButtons.filter(":checked").val();
12+
13+
if (val == "all") {
14+
rows.show();
15+
if (window.location.hash)
16+
window.location.hash = "";
17+
}
18+
else if (val == "forme" || val == "byme") {
19+
console.log(rows.filter("." + val))
20+
rows.filter("." + val).show();
21+
rows.not("." + val).hide();
22+
window.location.hash = val;
23+
}
24+
25+
// odd/even are swapped because the jQuery filter is 0-indexed
26+
rows.filter(":visible").filter(":even").removeClass("even").addClass("odd");
27+
rows.filter(":visible").filter(":odd").removeClass("odd").addClass("even");
28+
}
29+
30+
radioButtons.click(updateDisplayedRows);
31+
32+
updateDisplayedRows();
33+
});

0 commit comments

Comments
 (0)