예제 #1
0
def edit( request, id ):
    email_uri = mail_api.id2uri(id)
    email = mail_api.get_email(email_uri)

    if request.method == 'POST':
        subject = request.POST.get('subject')
        html_body = _rewrite_links(request.POST.get('body_text'))
        text_body = _text_from_html(html_body)
        tags = request.POST.get('tags')
        sequence = int(request.POST.get('to').split('-')[1])
        audience = request.POST.get('to').split('-')[0]

        mail_api.update_email(email_uri, subject, text_body, html_body, 
            sequence, audience, tags)
        return http.HttpResponseRedirect(reverse('mail_schedule'))

    context = {
        'sequences': sequence_model.get_all_sequences(),
        'email': email,
    }
    return render_to_response(
        'mail/compose.html',
        context,
        context_instance=RequestContext(request)
    )
예제 #2
0
 def test_update_email(self):
     email = mail_model.save_email(*self.EMAIL_PARAMS)
     mail_model.update_email(email['uri'], 'New sub', 'New Text', '', 2, 'individuals', 'tag1')
     email2 = mail_model.get_email(email['uri'])
     self.assertNotEqual(email, email2)
     self.assertEqual(email2['subject'], 'New sub')
     self.assertEqual(email2['text_body'], 'New Text')
     self.assertEqual(email2['html_body'], '')
     self.assertEqual(email2['sequence'], 2)
     self.assertEqual(email2['audience'], 'individuals')
     self.assertEqual(email2['tags'], 'tag1')
예제 #3
0
 def test_update_email(self):
     email = mail_model.save_email(*self.EMAIL_PARAMS)
     mail_model.update_email(email['uri'], 'New sub', 'New Text', '', 2,
                             'individuals', 'tag1')
     email2 = mail_model.get_email(email['uri'])
     self.assertNotEqual(email, email2)
     self.assertEqual(email2['subject'], 'New sub')
     self.assertEqual(email2['text_body'], 'New Text')
     self.assertEqual(email2['html_body'], '')
     self.assertEqual(email2['sequence'], 2)
     self.assertEqual(email2['audience'], 'individuals')
     self.assertEqual(email2['tags'], 'tag1')
예제 #4
0
def edit(request, id):
    email_uri = mail_api.id2uri(id)
    email = mail_api.get_email(email_uri)

    if request.method == 'POST':
        subject = request.POST.get('subject')
        html_body = _rewrite_links(request.POST.get('body_text'))
        text_body = _text_from_html(html_body)
        tags = request.POST.get('tags')
        sequence = int(request.POST.get('to').split('-')[1])
        audience = request.POST.get('to').split('-')[0]

        mail_api.update_email(email_uri, subject, text_body, html_body,
                              sequence, audience, tags)
        return http.HttpResponseRedirect(reverse('mail_schedule'))

    context = {
        'sequences': sequence_model.get_all_sequences(),
        'email': email,
    }
    return render_to_response('mail/compose.html',
                              context,
                              context_instance=RequestContext(request))