Skip to content

Commit 700db39

Browse files
committed
Secretariat can edit position of Area Directors
- Legacy-Id: 2287
1 parent 35577dc commit 700db39

6 files changed

Lines changed: 68 additions & 13 deletions

File tree

branch/iesg-tracker/ietf/idrfc/idrfc_wrapper.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -625,13 +625,16 @@ def _init(self):
625625
'comment_date':c.date,
626626
'comment_revision':str(c.revision),
627627
'ad_name':str(c.ad),
628+
'ad_username': c.ad.login_name,
628629
'position':'No Record',
629630
'is_old_ad':False})
630631
ads.add(str(c.ad))
631632
if self.ballot_active:
632633
for ad in IESGLogin.active_iesg():
633634
if str(ad) not in ads:
634-
positions.append({"ad_name":str(ad), "position":"No Record"})
635+
positions.append(dict(ad_name=str(ad),
636+
ad_username=ad.login_name,
637+
position="No Record"))
635638
self._positions = positions
636639

637640
def position_for_ad(self, ad_name):
@@ -696,7 +699,9 @@ def create_position_object(ballot, position, all_comments):
696699
p = v
697700
if not p:
698701
p = "No Record"
699-
r = {"ad_name":str(position.ad), "position":p}
702+
r = dict(ad_name=str(position.ad),
703+
ad_username=position.ad.login_name,
704+
position=p)
700705
if not position.ad.is_current_ad():
701706
r['is_old_ad'] = True
702707

branch/iesg-tracker/ietf/idrfc/tests.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,30 @@ def test_edit_position(self):
294294
self.assertTrue(pos.discuss == -1)
295295
self.assertEquals(draft.idinternal.comments().count(), comments_before + 1)
296296
self.assertTrue("Position" in draft.idinternal.comments()[0].comment_text)
297+
298+
def test_edit_position_as_secretary(self):
299+
draft = InternetDraft.objects.get(filename="draft-ietf-mipshop-pfmipv6")
300+
url = urlreverse('doc_edit_position', kwargs=dict(name=draft.filename))
301+
url += "?ad=rhousley"
302+
login_testing_unauthorized(self, "klm", url)
303+
304+
# normal get
305+
r = self.client.get(url)
306+
self.assertEquals(r.status_code, 200)
307+
q = PyQuery(r.content)
308+
self.assertTrue(len(q('form input[name=position]')) > 0)
309+
310+
# vote for rhousley
311+
comments_before = draft.idinternal.comments().count()
312+
self.assertTrue(not Position.objects.filter(ballot=draft.idinternal.ballot, ad__login_name="rhousley"))
313+
314+
r = self.client.post(url, dict(position="discuss"))
315+
self.assertEquals(r.status_code, 302)
316+
317+
pos = Position.objects.get(ballot=draft.idinternal.ballot, ad__login_name="rhousley")
318+
self.assertTrue(pos.discuss)
319+
self.assertTrue(not (pos.yes or pos.noobj or pos.abstain or pos.recuse))
320+
297321

298322
def test_send_ballot_comment(self):
299323
draft = InternetDraft.objects.get(filename="draft-ietf-mipshop-pfmipv6")

branch/iesg-tracker/ietf/idrfc/views_ballot.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,16 @@ def edit_position(request, name):
6363
if not doc.idinternal:
6464
raise Http404()
6565

66-
login = IESGLogin.objects.get(login_name=request.user.username)
67-
68-
pos, discuss, comment = get_ballot_info(doc.idinternal.ballot, login)
66+
ad = login = IESGLogin.objects.get(login_name=request.user.username)
67+
68+
# if we're in the Secretariat, we can select an AD to act as stand-in for
69+
if not in_group(request.user, "Area_Director"):
70+
ad_username = request.GET.get('ad')
71+
if not ad_username:
72+
raise Http404()
73+
ad = get_object_or_404(IESGLogin, login_name=ad_username)
74+
75+
pos, discuss, comment = get_ballot_info(doc.idinternal.ballot, ad)
6976

7077
if request.method == 'POST':
7178
form = EditPositionForm(request.POST)
@@ -78,7 +85,7 @@ def edit_position(request, name):
7885
if pos.discuss:
7986
pos.discuss = -1
8087
else:
81-
pos = Position(ballot=doc.idinternal.ballot, ad=login)
88+
pos = Position(ballot=doc.idinternal.ballot, ad=ad)
8289
pos.discuss = 0
8390

8491
old_vote = position_to_ballot_choice(pos)
@@ -98,7 +105,7 @@ def edit_position(request, name):
98105
# save discuss
99106
if (discuss and clean['discuss_text'] != discuss.text) or (clean['discuss_text'] and not discuss):
100107
if not discuss:
101-
discuss = IESGDiscuss(ballot=doc.idinternal.ballot, ad=login)
108+
discuss = IESGDiscuss(ballot=doc.idinternal.ballot, ad=ad)
102109

103110
discuss.text = clean['discuss_text']
104111
discuss.date = date.today()
@@ -118,7 +125,7 @@ def edit_position(request, name):
118125
# than doing a clever hack here)
119126
if (comment and clean['comment_text'] != comment.text) or (clean['comment_text'] and not comment):
120127
if not comment:
121-
comment = IESGComment(ballot=doc.idinternal.ballot, ad=login)
128+
comment = IESGComment(ballot=doc.idinternal.ballot, ad=ad)
122129

123130
comment.text = clean['comment_text']
124131
comment.date = date.today()
@@ -153,7 +160,8 @@ def edit_position(request, name):
153160
dict(doc=doc,
154161
form=form,
155162
discuss=discuss,
156-
comment=comment),
163+
comment=comment,
164+
ad=ad),
157165
context_instance=RequestContext(request))
158166

159167
@group_required('Area_Director','Secretariat')

branch/iesg-tracker/ietf/templates/idrfc/doc_ballot.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,12 @@
3535
<table class="ietf-ballot"><tr valign="top"><td class="left">
3636

3737
{% if doc_ballot_edit_button and user|in_group:"Area_Director,Secretariat" %}
38+
{% if user|in_group:"Area_Director" %}
3839
<div style="margin-top:8px; margin-bottom:8px;"><span id="doc_ballot_button" class="yui-button yui-link-button"><span class="first-child"><a href="{% url doc_edit_position name=doc.draft_name %}">Edit position</a></span></span></div>
40+
{% endif %}
3941

4042
{% if ballot.was_deferred %}
41-
<div style="margin-top:8px; margin-bottom:8px;"><span id="doc_defer_ballot_button" class="yui-button yui-link-button"><span class="first-child"><a href="{% url doc_undefer_ballot name=doc.draft_name %}">Undefer ballot</a></span></span></div>
43+
<div style="margin-top:8px; margin-bottom:8px;"><span id="doc_undefer_ballot_button" class="yui-button yui-link-button"><span class="first-child"><a href="{% url doc_undefer_ballot name=doc.draft_name %}">Undefer ballot</a></span></span></div>
4244
<div style="margin-top:8px; margin-bottom:8px;">Ballot deferred by {{ ballot.deferred_by }} on {{ ballot.deferred_date }}.</div>
4345
{% else %}
4446
<div style="margin-top:8px; margin-bottom:8px;"><span id="doc_defer_ballot_button" class="yui-button yui-link-button"><span class="first-child"><a href="{% url doc_defer_ballot name=doc.draft_name %}">Defer ballot</a></span></span></div>

branch/iesg-tracker/ietf/templates/idrfc/doc_ballot_list.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
{% load ietf_filters %}
12
{% for p in positions %}
2-
{% if p.is_old_ad %}[{%endif%}{{p.ad_name}}{% if p.is_old_ad %}]{%endif%}{% if p.has_text %}&nbsp;<a href="#{{p.ad_name|slugify}}"><img src="/images/comment.png" width="14" height="12" alt="*" border="0"/></a>{% endif %}<br/>
3+
{% if p.is_old_ad %}[{%endif%}<a{% if user|in_group:"Secretariat" %} href="{% url doc_edit_position name=doc.draft_name %}?ad={{ p.ad_username }}" title="Click to edit the position of {{ p.ad_name }}"{% endif %}>{{p.ad_name}}</a>{% if p.is_old_ad %}]{%endif%}{% if p.has_text %}&nbsp;<a href="#{{p.ad_name|slugify}}"><img src="/images/comment.png" width="14" height="12" alt="*" border="0"/></a>{% endif %}<br/>
34
{% if p.old_positions %}<span class="was">(was {{p.old_positions|join:", "}})</span><br/>{%endif%}
45
{% empty %}
56
<i>none</i>

branch/iesg-tracker/ietf/templates/idrfc/edit_position.html

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,40 @@
22
form.position-form .position ul {
33
padding: 0;
44
margin: 0;
5-
}
5+
}
6+
67
form.position-form .position li {
78
list-style-type: none;
89
float: left;
910
padding-right: 10px;
1011
}
12+
1113
form.position-form .discuss-text {
1214
clear: left;
15+
padding-top: 20px
16+
}
17+
18+
form.position-form #id_discuss_text,
19+
form.position-form #id_comment_text {
20+
width: 700px;
21+
height: 300px;
22+
}
23+
24+
form.position-form .comment-text {
25+
margin-top: 20px;
1326
}
1427
</style>
1528

29+
<h3>Change position for {{ ad }}</h3>
30+
1631
<form class="position-form" action="" method="POST">
1732
<div class="position">{{ form.position }}</div>
1833

1934
<div class="discuss-text">{{ form.discuss_text.label_tag }}: {% if discuss %}(last edited {{ discuss.date }}){% endif %}</div>
2035
{{ form.discuss_text }}
2136

2237
<div class="comment-text">{{ form.comment_text.label_tag }}: {% if comment %}(last edited {{ comment.date }}){% endif %}</div>
23-
<div>{{ form.comment_text }}</div>
38+
{{ form.comment_text }}
2439

2540
<div class="actions">
2641
<a href="{{ doc.idinternal.get_absolute_url }}">Back</a>

0 commit comments

Comments
 (0)