|
28 | 28 | from ietf.person.models import Person |
29 | 29 | from ietf.utils.mail import send_mail_text, send_mail_preformatted |
30 | 30 | from ietf.mailtoken.utils import gather_address_lists |
| 31 | +from ietf.mailtoken.forms import CcSelectForm |
31 | 32 |
|
32 | 33 | BALLOT_CHOICES = (("yes", "Yes"), |
33 | 34 | ("noobj", "No Objection"), |
@@ -287,29 +288,32 @@ def send_ballot_comment(request, name, ballot_id): |
287 | 288 | addrs = gather_address_lists('ballot_saved',doc=doc) |
288 | 289 |
|
289 | 290 | 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) |
298 | 298 |
|
299 | 299 | send_mail_text(request, addrs.to, frm, subject, body, cc=u", ".join(cc)) |
300 | 300 |
|
301 | 301 | return HttpResponseRedirect(return_to_url) |
| 302 | + |
| 303 | + else: |
| 304 | + |
| 305 | + cc_select_form = CcSelectForm(mailtoken_slug='ballot_saved',mailtoken_context={'doc':doc}) |
302 | 306 |
|
303 | 307 | return render_to_response('doc/ballot/send_ballot_comment.html', |
304 | 308 | dict(doc=doc, |
305 | 309 | subject=subject, |
306 | 310 | body=body, |
307 | 311 | frm=frm, |
308 | 312 | to=addrs.as_strings().to, |
309 | | - cc=addrs.as_strings().cc, |
310 | 313 | ad=ad, |
311 | 314 | can_send=d or c, |
312 | 315 | back_url=back_url, |
| 316 | + cc_select_form = cc_select_form, |
313 | 317 | ), |
314 | 318 | context_instance=RequestContext(request)) |
315 | 319 |
|
|
0 commit comments