Skip to content

Commit 4e61776

Browse files
committed
Smarter send_ballot_comment form
- Legacy-Id: 10054
1 parent 90c3426 commit 4e61776

5 files changed

Lines changed: 34 additions & 36 deletions

File tree

ietf/doc/tests_ballot.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,12 @@ def test_send_ballot_comment(self):
147147
r = self.client.get(url)
148148
self.assertEqual(r.status_code, 200)
149149
q = PyQuery(r.content)
150-
self.assertTrue(len(q('form input[name="cc"]')) > 0)
150+
self.assertTrue(len(q('form input[name="extra_cc"]')) > 0)
151151

152152
# send
153153
mailbox_before = len(outbox)
154154

155-
r = self.client.post(url, dict(cc="test298347@example.com", cc_state_change="1",cc_group_list="1"))
155+
r = self.client.post(url, dict(extra_cc="test298347@example.com", cc_tokens=['doc_notify','doc_group_chairs']))
156156
self.assertEqual(r.status_code, 302)
157157

158158
self.assertEqual(len(outbox), mailbox_before + 1)
@@ -163,10 +163,14 @@ def test_send_ballot_comment(self):
163163
self.assertTrue("clearer title" in str(m))
164164
self.assertTrue("Test!" in str(m))
165165
self.assertTrue("iesg@" in m['To'])
166+
# cc_token doc_group_chairs
167+
self.assertTrue("mars-chairs@" in m['Cc'])
168+
# cc_token doc_notify
166169
self.assertTrue("somebody@example.com" in m['Cc'])
170+
# cc_token doc_group_email_list was not selected
171+
self.assertFalse(draft.group.list_email in m['Cc'])
172+
# extra-cc
167173
self.assertTrue("test298347@example.com" in m['Cc'])
168-
self.assertTrue(draft.group.list_email)
169-
self.assertTrue(draft.group.list_email in m['Cc'])
170174

171175
r = self.client.post(url, dict(cc=""))
172176
self.assertEqual(r.status_code, 302)

ietf/doc/views_ballot.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
from ietf.person.models import Person
2929
from ietf.utils.mail import send_mail_text, send_mail_preformatted
3030
from ietf.mailtoken.utils import gather_address_lists
31+
from ietf.mailtoken.forms import CcSelectForm
3132

3233
BALLOT_CHOICES = (("yes", "Yes"),
3334
("noobj", "No Objection"),
@@ -287,29 +288,32 @@ def send_ballot_comment(request, name, ballot_id):
287288
addrs = gather_address_lists('ballot_saved',doc=doc)
288289

289290
if request.method == 'POST':
290-
# The send_ballot_comments form provides an unusual case where the form separates out
291-
# the cc addresses to be edited before sending into a separate field
292-
# TODO: We should consider undoing this, and going back at most to an "extra_cc" model
293-
cc = [x.strip() for x in request.POST.get("cc", "").split(',') if x.strip()]
294-
if request.POST.get("cc_state_change") and doc.notify:
295-
cc.extend(doc.notify.split(','))
296-
if request.POST.get("cc_group_list") and doc.group.list_email:
297-
cc.append(doc.group.list_email)
291+
cc = []
292+
cc_select_form = CcSelectForm(data=request.POST,mailtoken_slug='ballot_saved',mailtoken_context={'doc':doc})
293+
if cc_select_form.is_valid():
294+
cc.extend(cc_select_form.get_selected_addresses())
295+
extra_cc = [x.strip() for x in request.POST.get("extra_cc","").split(',') if x.strip()]
296+
if extra_cc:
297+
cc.extend(extra_cc)
298298

299299
send_mail_text(request, addrs.to, frm, subject, body, cc=u", ".join(cc))
300300

301301
return HttpResponseRedirect(return_to_url)
302+
303+
else:
304+
305+
cc_select_form = CcSelectForm(mailtoken_slug='ballot_saved',mailtoken_context={'doc':doc})
302306

303307
return render_to_response('doc/ballot/send_ballot_comment.html',
304308
dict(doc=doc,
305309
subject=subject,
306310
body=body,
307311
frm=frm,
308312
to=addrs.as_strings().to,
309-
cc=addrs.as_strings().cc,
310313
ad=ad,
311314
can_send=d or c,
312315
back_url=back_url,
316+
cc_select_form = cc_select_form,
313317
),
314318
context_instance=RequestContext(request))
315319

ietf/mailtoken/migrations/0002_auto_20150809_1314.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def make_recipients(apps):
111111

112112
rc(slug='group_chairs',
113113
desc="The group's chairs",
114-
template="{{group.acronym}}-chairs@ietf.org")
114+
template="<{{group.acronym}}-chairs@ietf.org>")
115115

116116
rc(slug='group_responsible_directors',
117117
desc="The group's responsible AD(s) or IRTF chair",
@@ -265,7 +265,9 @@ def mt_factory(slug,desc,to_slugs,cc_slugs=[]):
265265
"(with discusses, other blocking positions, "
266266
"or comments) is saved",
267267
to_slugs=['iesg'],
268-
cc_slugs=['doc_authors',
268+
cc_slugs=['doc_notify',
269+
'doc_group_mail_list',
270+
'doc_authors',
269271
'doc_group_chairs',
270272
'doc_shepherd',
271273
'doc_affecteddoc_authors',

ietf/name/fixtures/names.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4473,7 +4473,7 @@
44734473
},
44744474
{
44754475
"fields": {
4476-
"template": "{{group.acronym}}-chairs@ietf.org",
4476+
"template": "<{{group.acronym}}-chairs@ietf.org>",
44774477
"desc": "The group's chairs"
44784478
},
44794479
"model": "mailtoken.recipient",
@@ -4897,6 +4897,8 @@
48974897
"doc_affecteddoc_notify",
48984898
"doc_authors",
48994899
"doc_group_chairs",
4900+
"doc_group_mail_list",
4901+
"doc_notify",
49004902
"doc_shepherd"
49014903
],
49024904
"to": [

ietf/templates/doc/ballot/send_ballot_comment.html

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,16 @@ <h1>Send ballot position for {{ ad }} on <a href="{% url "doc_view" name=doc.can
2525
<input class="form-control" type="text" placeholder="{{ to }}" disabled>
2626
</div>
2727

28+
<div class="form-group">
29+
{% bootstrap_form cc_select_form %}
30+
</div>
31+
2832
<div class="form-group">
29-
<label>Cc</label>
30-
<input class="form-control" type="email" name="cc">
33+
<label>Additional Cc Addresses</label>
34+
<input class="form-control" type="email" name="extra_cc">
3135
<div class="help-block">Separate email addresses with commas.</div>
3236
</div>
3337

34-
{% if doc.notify %}
35-
<div class="checkbox">
36-
<label>
37-
<input type="checkbox" name="cc_state_change" value="1" checked>
38-
<b>Cc:</b> {{ doc.notify }}
39-
</label>
40-
</div>
41-
{% endif %}
42-
43-
{% if doc.group.list_email %}
44-
<div class="checkbox">
45-
<label>
46-
<input type="checkbox" name="cc_group_list" value="1" checked>
47-
<b>Cc:</b> {{ doc.group.list_email }}
48-
</label>
49-
</div>
50-
{% endif %}
51-
5238
<div class="form-group">
5339
<label>Subject</label>
5440
<input class="form-control" type="text" placeholder="{{ subject }}" disabled>

0 commit comments

Comments
 (0)