Esempio n. 1
0
 def test_vcard_format(self):
     contact = Contact(email='*****@*****.**',
                       first_name='Toto',
                       last_name='Titi')
     self.assertEquals(contact.vcard_format(), 'BEGIN:VCARD\r\nVERSION:3.0\r\n'\
                       'EMAIL;TYPE=INTERNET:[email protected]\r\nFN:Toto Titi\r\n'\
                       'N:Titi;Toto;;;\r\nEND:VCARD\r\n')
Esempio n. 2
0
def view_mailinglist_unsubscribe_notrack(request):
    """Unsubscribe a contact to a mailing list"""
    user_email = request.POST.get("email")
    message = ""
    if user_email:
        try:
            contact = Contact.objects.get(email=user_email)
            contactsave = Contact(
                pk=contact.pk,
                email=contact.email,
                first_name=contact.first_name,
                last_name=contact.last_name,
                subscriber=False,
                content_type=contact.content_type,
                object_id=contact.object_id,
                content_object=contact.content_object,
                creation_date=contact.creation_date,
                modification_date=contact.modification_date,
            )
            contactsave.save()
            finished = True
            return render_to_response(
                "newsletter/mailing_list_unsubscribe_notrack.html",
                {"finished": finished},
                context_instance=RequestContext(request),
            )
        except:
            message = "A user with that email does not exist."
    else:
        message = "No email have been entered."
    return render_to_response(
        "newsletter/mailing_list_unsubscribe_notrack.html",
        {"message": message},
        context_instance=RequestContext(request),
    )
Esempio n. 3
0
 def test_mail_format(self):
     contact = Contact(email='*****@*****.**')
     self.assertEquals(contact.mail_format(), '*****@*****.**')
     contact = Contact(email='*****@*****.**', first_name='Toto')
     self.assertEquals(contact.mail_format(), '*****@*****.**')
     contact = Contact(email='*****@*****.**', first_name='Toto', last_name='Titi')
     self.assertEquals(contact.mail_format(), 'Titi Toto <*****@*****.**>')
Esempio n. 4
0
def newsletter_subscribe(request):
    if request.POST:
        news_form = NewsletterForm(request.POST)
        if news_form.is_valid():
            data = news_form.cleaned_data
            contact = Contact(email=data['email'],content_object=data['city'])
            contact.save()
            mailing, created = MailingList.objects.get_or_create(name=data['city'].slug)
            mailing.subscribers.add(contact)
            mailing.save()
            return HttpResponseRedirect(reverse('newsletter_subscribe_success'))
    else:
        city = request.session.get('CURRENT_CITY')
        news_form = NewsletterForm(initial={'city':city and city.id or None})
    return render_to_response('newsletter/cadastro.html',locals(),context_instance=RequestContext(request))  
Esempio n. 5
0
 def test_mail_format(self):
     contact = Contact(email='*****@*****.**')
     self.assertEquals(contact.mail_format(), '*****@*****.**')
     contact = Contact(email='*****@*****.**', first_name='Toto')
     self.assertEquals(contact.mail_format(), '*****@*****.**')
     contact = Contact(email='*****@*****.**', first_name='Toto', last_name='Titi')
     self.assertEquals(contact.mail_format(), 'Titi Toto <*****@*****.**>')
Esempio n. 6
0
 def test_vcard_format(self):
     contact = Contact(email='*****@*****.**', first_name='Toto', last_name='Titi')
     self.assertEquals(contact.vcard_format(), 'BEGIN:VCARD\r\nVERSION:3.0\r\n'\
                       'EMAIL;TYPE=INTERNET:[email protected]\r\nFN:Toto Titi\r\n'\
                       'N:Titi;Toto;;;\r\nEND:VCARD\r\n')
Esempio n. 7
0
 def test_unique(self):
     Contact(email='*****@*****.**').save()
     self.assertRaises(IntegrityError,
                       Contact(email='*****@*****.**').save)