Skip to content

Commit 51ab793

Browse files
committed
Merged [2496] from rjsparks@nostrum.com: Changed the navigation round editing ballots and sending discuss/email so that the user comes back to the page the edit started from.
- Legacy-Id: 2519 Note: SVN reference [2496] has been migrated to Git commit eccf544
1 parent d3292a8 commit 51ab793

4 files changed

Lines changed: 44 additions & 9 deletions

File tree

ietf/idrfc/tests.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,6 @@ def test_edit_position(self):
421421
self.assertEquals(len(pos), 0)
422422
self.assertEquals(draft.idinternal.comments().count(), comments_before + 1)
423423
self.assertTrue("Position" in draft.idinternal.comments()[0].comment_text)
424-
425424
def test_edit_position_as_secretary(self):
426425
draft = InternetDraft.objects.get(filename="draft-ietf-mipshop-pfmipv6")
427426
url = urlreverse('doc_edit_position', kwargs=dict(name=draft.filename))

ietf/idrfc/views_ballot.py

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class EditPositionForm(forms.Form):
5555
position = forms.ChoiceField(choices=BALLOT_CHOICES, widget=forms.RadioSelect, required=False)
5656
discuss_text = forms.CharField(required=False, widget=forms.Textarea)
5757
comment_text = forms.CharField(required=False, widget=forms.Textarea)
58+
return_to_url = forms.CharField(required=False, widget=forms.HiddenInput)
5859

5960
@group_required('Area_Director','Secretariat')
6061
def edit_position(request, name):
@@ -65,6 +66,12 @@ def edit_position(request, name):
6566

6667
ad = login = IESGLogin.objects.get(login_name=request.user.username)
6768

69+
if 'HTTP_REFERER' in request.META:
70+
return_to_url = request.META['HTTP_REFERER']
71+
else:
72+
return_to_url = doc.idinternal.get_absolute_url()
73+
74+
6875
# if we're in the Secretariat, we can select an AD to act as stand-in for
6976
if not in_group(request.user, "Area_Director"):
7077
ad_username = request.GET.get('ad')
@@ -77,8 +84,13 @@ def edit_position(request, name):
7784
if request.method == 'POST':
7885
form = EditPositionForm(request.POST)
7986
if form.is_valid():
87+
8088
# save the vote
8189
clean = form.cleaned_data
90+
91+
if clean['return_to_url']:
92+
return_to_url = clean['return_to_url']
93+
8294
vote = clean['position']
8395
if pos:
8496
# mark discuss as cleared (quirk from old system)
@@ -142,13 +154,14 @@ def edit_position(request, name):
142154

143155
doc.idinternal.event_date = date.today()
144156
doc.idinternal.save()
157+
145158
if request.POST.get("send_mail"):
146-
qstr = ""
159+
qstr = "?return_to_url=%s" % return_to_url
147160
if request.GET.get('ad'):
148-
qstr = "?ad=%s" % request.GET.get('ad')
161+
qstr += "&ad=%s" % request.GET.get('ad')
149162
return HttpResponseRedirect(urlreverse("doc_send_ballot_comment", kwargs=dict(name=doc.filename)) + qstr)
150163
else:
151-
return HttpResponseRedirect(doc.idinternal.get_absolute_url())
164+
return HttpResponseRedirect(return_to_url)
152165
else:
153166
initial = {}
154167
if pos:
@@ -159,15 +172,21 @@ def edit_position(request, name):
159172

160173
if comment:
161174
initial['comment_text'] = comment.text
175+
176+
if return_to_url:
177+
initial['return_to_url'] = return_to_url
162178

163179
form = EditPositionForm(initial=initial)
164180

181+
165182
return render_to_response('idrfc/edit_position.html',
166183
dict(doc=doc,
167184
form=form,
168185
discuss=discuss,
169186
comment=comment,
170-
ad=ad),
187+
ad=ad,
188+
return_to_url=return_to_url,
189+
),
171190
context_instance=RequestContext(request))
172191

173192
@group_required('Area_Director','Secretariat')
@@ -178,6 +197,18 @@ def send_ballot_comment(request, name):
178197
raise Http404()
179198

180199
ad = login = IESGLogin.objects.get(login_name=request.user.username)
200+
201+
return_to_url = request.GET.get('return_to_url')
202+
if not return_to_url:
203+
return_to_url = doc.idinternal.get_absolute_url()
204+
205+
if 'HTTP_REFERER' in request.META:
206+
back_url = request.META['HTTP_REFERER']
207+
else:
208+
back_url = doc.idinternal.get_absolute_url()
209+
210+
211+
181212
# if we're in the Secretariat, we can select an AD to act as stand-in for
182213
if not in_group(request.user, "Area_Director"):
183214
ad_username = request.GET.get('ad')
@@ -210,7 +241,7 @@ def send_ballot_comment(request, name):
210241

211242
send_mail_text(request, to, frm, subject, body, cc=", ".join(cc))
212243

213-
return HttpResponseRedirect(doc.idinternal.get_absolute_url())
244+
return HttpResponseRedirect(return_to_url)
214245

215246
return render_to_response('idrfc/send_ballot_comment.html',
216247
dict(doc=doc,
@@ -219,7 +250,9 @@ def send_ballot_comment(request, name):
219250
frm=frm,
220251
to=to,
221252
ad=ad,
222-
can_send=d or c),
253+
can_send=d or c,
254+
back_url=back_url,
255+
),
223256
context_instance=RequestContext(request))
224257

225258

ietf/templates/idrfc/edit_position.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,13 @@ <h1>Change position for {{ ad }}</h1>
5151
{{ form.comment_text }}
5252

5353
<div class="actions">
54-
<a href="{{ doc.idinternal.get_absolute_url }}">Back</a>
54+
<a href="{{ return_to_url }}">Back</a>
5555
<input type="submit" name="send_mail" value="Save and send email"/>
5656
<input type="submit" value="Save"/>
5757
</div>
58+
59+
{{ form.return_to_url }}
60+
5861
</form>
5962
{% endblock %}
6063

ietf/templates/idrfc/send_ballot_comment.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ <h1>Email Discuss and Comment text for {{ ad }} to IESG list</h1>
3838
<tr>
3939
<td></td>
4040
<td class="actions">
41-
<a href="{{ doc.idinternal.get_absolute_url }}">Back</a>
41+
<a href="{{ back_url }}">Back</a>
4242
<input type="submit" value="Send"/>
4343
</td>
4444
</tr>

0 commit comments

Comments
 (0)