コード例 #1
0
ファイル: views.py プロジェクト: emperorcezar/OpenConnect
def pending_email(sender, contact=None, event=None, **kwargs):
    assert event
    assert contact
    from django.core.mail import EmailMultiAlternatives

    price = event.get_price(contact)

    if event.pending_message:
        custom_text = pretty_print(event.pending_message)

        mail = EmailMultiAlternatives("Registration pending for %s" %(event, ),
                                      render_to_string("registration_pending.txt", locals()),
                                      FROM_EMAIL,
                                      ['"%s %s" <%s>' % (contact.first_name, contact.last_name, contact.email)]
                                      )

        mail.attach_alternative(render_to_string("registration_pending_email.html", locals()), "text/html")
        mail.send()
        email_log.info("Sent Email To:%s - From:%s - Subject:%s" % (contact.email, FROM_EMAIL, "Registration pending for %s" %(event, )))
コード例 #2
0
ファイル: views.py プロジェクト: emperorcezar/OpenConnect
def email_register(request, slug):
    if request.method == 'POST':
        contact = get(Contact, email=request.POST.get('email', None))
        event = get(Event, slug=slug)
        registrant = Registrant(contact = contact, event = event, pending = True, discount_code = request.POST.get('discount_code', None))
        try:
            registrant.save()
        except ValueError, e:
            if str(e) == 'Already Registered':
                error = 'That email address is already registered'
                return render_to_response('event_email_register.html', locals())
            else:
                print e
                raise

        from django.core.mail import EmailMultiAlternatives


            

        incorrect_link = "http://"+DOMAIN+reverse('event-register-token', kwargs={'slug':slug,'token':contact.get_token()})+"/"

        message = render_to_string("email_register_message.txt", locals())
        html_message = render_to_string("email_register_message.html", locals())
        
        mail = EmailMultiAlternatives("Registration Confirmation for %s" %(event, ),
                                      message,
                                      FROM_EMAIL,
                                      ['"%s %s" <%s>' % (contact.first_name, contact.last_name, contact.email)]
                                      )

        mail.attach_alternative(html_message, "text/html")
        mail.send()
        email_log.info("Sent Email To:%s - From:%s - Subject:%s" % (contact.email, FROM_EMAIL, "Registration Confirmation For %s" %(event, )))
        
        
        return render_to_response('registration_pending.html', locals())