Smarter send_ballot_comment form
- Legacy-Id: 10054
This commit is contained in:
parent
90c3426e2f
commit
4e61776c89
|
@ -147,12 +147,12 @@ class EditPositionTests(TestCase):
|
|||
r = self.client.get(url)
|
||||
self.assertEqual(r.status_code, 200)
|
||||
q = PyQuery(r.content)
|
||||
self.assertTrue(len(q('form input[name="cc"]')) > 0)
|
||||
self.assertTrue(len(q('form input[name="extra_cc"]')) > 0)
|
||||
|
||||
# send
|
||||
mailbox_before = len(outbox)
|
||||
|
||||
r = self.client.post(url, dict(cc="test298347@example.com", cc_state_change="1",cc_group_list="1"))
|
||||
r = self.client.post(url, dict(extra_cc="test298347@example.com", cc_tokens=['doc_notify','doc_group_chairs']))
|
||||
self.assertEqual(r.status_code, 302)
|
||||
|
||||
self.assertEqual(len(outbox), mailbox_before + 1)
|
||||
|
@ -163,10 +163,14 @@ class EditPositionTests(TestCase):
|
|||
self.assertTrue("clearer title" in str(m))
|
||||
self.assertTrue("Test!" in str(m))
|
||||
self.assertTrue("iesg@" in m['To'])
|
||||
# cc_token doc_group_chairs
|
||||
self.assertTrue("mars-chairs@" in m['Cc'])
|
||||
# cc_token doc_notify
|
||||
self.assertTrue("somebody@example.com" in m['Cc'])
|
||||
# cc_token doc_group_email_list was not selected
|
||||
self.assertFalse(draft.group.list_email in m['Cc'])
|
||||
# extra-cc
|
||||
self.assertTrue("test298347@example.com" in m['Cc'])
|
||||
self.assertTrue(draft.group.list_email)
|
||||
self.assertTrue(draft.group.list_email in m['Cc'])
|
||||
|
||||
r = self.client.post(url, dict(cc=""))
|
||||
self.assertEqual(r.status_code, 302)
|
||||
|
|
|
@ -28,6 +28,7 @@ from ietf.name.models import BallotPositionName
|
|||
from ietf.person.models import Person
|
||||
from ietf.utils.mail import send_mail_text, send_mail_preformatted
|
||||
from ietf.mailtoken.utils import gather_address_lists
|
||||
from ietf.mailtoken.forms import CcSelectForm
|
||||
|
||||
BALLOT_CHOICES = (("yes", "Yes"),
|
||||
("noobj", "No Objection"),
|
||||
|
@ -287,18 +288,21 @@ def send_ballot_comment(request, name, ballot_id):
|
|||
addrs = gather_address_lists('ballot_saved',doc=doc)
|
||||
|
||||
if request.method == 'POST':
|
||||
# The send_ballot_comments form provides an unusual case where the form separates out
|
||||
# the cc addresses to be edited before sending into a separate field
|
||||
# TODO: We should consider undoing this, and going back at most to an "extra_cc" model
|
||||
cc = [x.strip() for x in request.POST.get("cc", "").split(',') if x.strip()]
|
||||
if request.POST.get("cc_state_change") and doc.notify:
|
||||
cc.extend(doc.notify.split(','))
|
||||
if request.POST.get("cc_group_list") and doc.group.list_email:
|
||||
cc.append(doc.group.list_email)
|
||||
cc = []
|
||||
cc_select_form = CcSelectForm(data=request.POST,mailtoken_slug='ballot_saved',mailtoken_context={'doc':doc})
|
||||
if cc_select_form.is_valid():
|
||||
cc.extend(cc_select_form.get_selected_addresses())
|
||||
extra_cc = [x.strip() for x in request.POST.get("extra_cc","").split(',') if x.strip()]
|
||||
if extra_cc:
|
||||
cc.extend(extra_cc)
|
||||
|
||||
send_mail_text(request, addrs.to, frm, subject, body, cc=u", ".join(cc))
|
||||
|
||||
return HttpResponseRedirect(return_to_url)
|
||||
|
||||
else:
|
||||
|
||||
cc_select_form = CcSelectForm(mailtoken_slug='ballot_saved',mailtoken_context={'doc':doc})
|
||||
|
||||
return render_to_response('doc/ballot/send_ballot_comment.html',
|
||||
dict(doc=doc,
|
||||
|
@ -306,10 +310,10 @@ def send_ballot_comment(request, name, ballot_id):
|
|||
body=body,
|
||||
frm=frm,
|
||||
to=addrs.as_strings().to,
|
||||
cc=addrs.as_strings().cc,
|
||||
ad=ad,
|
||||
can_send=d or c,
|
||||
back_url=back_url,
|
||||
cc_select_form = cc_select_form,
|
||||
),
|
||||
context_instance=RequestContext(request))
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ def make_recipients(apps):
|
|||
|
||||
rc(slug='group_chairs',
|
||||
desc="The group's chairs",
|
||||
template="{{group.acronym}}-chairs@ietf.org")
|
||||
template="<{{group.acronym}}-chairs@ietf.org>")
|
||||
|
||||
rc(slug='group_responsible_directors',
|
||||
desc="The group's responsible AD(s) or IRTF chair",
|
||||
|
@ -265,7 +265,9 @@ def make_mailtokens(apps):
|
|||
"(with discusses, other blocking positions, "
|
||||
"or comments) is saved",
|
||||
to_slugs=['iesg'],
|
||||
cc_slugs=['doc_authors',
|
||||
cc_slugs=['doc_notify',
|
||||
'doc_group_mail_list',
|
||||
'doc_authors',
|
||||
'doc_group_chairs',
|
||||
'doc_shepherd',
|
||||
'doc_affecteddoc_authors',
|
||||
|
|
|
@ -4473,7 +4473,7 @@
|
|||
},
|
||||
{
|
||||
"fields": {
|
||||
"template": "{{group.acronym}}-chairs@ietf.org",
|
||||
"template": "<{{group.acronym}}-chairs@ietf.org>",
|
||||
"desc": "The group's chairs"
|
||||
},
|
||||
"model": "mailtoken.recipient",
|
||||
|
@ -4897,6 +4897,8 @@
|
|||
"doc_affecteddoc_notify",
|
||||
"doc_authors",
|
||||
"doc_group_chairs",
|
||||
"doc_group_mail_list",
|
||||
"doc_notify",
|
||||
"doc_shepherd"
|
||||
],
|
||||
"to": [
|
||||
|
|
|
@ -25,30 +25,16 @@
|
|||
<input class="form-control" type="text" placeholder="{{ to }}" disabled>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
{% bootstrap_form cc_select_form %}
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Cc</label>
|
||||
<input class="form-control" type="email" name="cc">
|
||||
<label>Additional Cc Addresses</label>
|
||||
<input class="form-control" type="email" name="extra_cc">
|
||||
<div class="help-block">Separate email addresses with commas.</div>
|
||||
</div>
|
||||
|
||||
{% if doc.notify %}
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" name="cc_state_change" value="1" checked>
|
||||
<b>Cc:</b> {{ doc.notify }}
|
||||
</label>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if doc.group.list_email %}
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" name="cc_group_list" value="1" checked>
|
||||
<b>Cc:</b> {{ doc.group.list_email }}
|
||||
</label>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="form-group">
|
||||
<label>Subject</label>
|
||||
<input class="form-control" type="text" placeholder="{{ subject }}" disabled>
|
||||
|
|
Loading…
Reference in a new issue