Ejemplo n.º 1
0
def email_template_test_send(request, template_id):
    et = EMailTemplate.get_by_id(int(template_id))
    if et  is None:
        raise Http404

    if request.method == 'POST':
        form = EMailAddressForm(request.POST)
        if form.is_valid():
            to_a = form.cleaned_data['address']
            logging.info('test send template id %d, to: %s', et.key().id(), to_a)
            
            try:
                email = EmailMessage(et.data)
                email.sender = getConfig('DEFAULT_SENDER')
                email.to = to_a
                email.check_initialized()

                if getConfigBool("ENABLE_MAIL_TEST",False):
                    logging.info('sending...')
                    email.send()
                else:
                    logging.info('disabled')
        

            except:
                logging.info("can't init email! %s"%sys.exc_info()[1])
                return HttpResponse("can't init email - %s"%sys.exc_info()[1])


            return redirect('..')
    else:
        form = EMailAddressForm()
 
    return render_to_response('emails/email_template_test_send.html', RequestContext(request, { 'form' : form, 'et':et}))
Ejemplo n.º 2
0
def email_template_edit(request, template_id):
    et = EMailTemplate.get_by_id(int(template_id))
    if et  is None:
        raise Http404
    
    if request.method == 'POST':
        form = EMailTemplateForm(request.POST)
        if form.is_valid():
            et.name = form.cleaned_data['name']
            et.open_for_import = form.cleaned_data['open_for_import']
            et.save()
            return redirect('../..')
    else:
        form = EMailTemplateForm(instance=et)
    return render_to_response('emails/email_template_edit.html', RequestContext(request, { 'form' : form}))
Ejemplo n.º 3
0
def process_incoming_email_template(template_id, data):
    logging.info('processing incoming email template')
    et = EMailTemplate.get_by_id(int(template_id))
    if et is None:
        logging.info('template not found')
        return

    if not et.open_for_import:
        logging.info('template is not open')
        return

    et.data = data
    et.open_for_import = False

    et.save()

    logging.info('template updated and closed')
Ejemplo n.º 4
0
def email_template_show(request, template_id):
    et = EMailTemplate.get_by_id(int(template_id))
    if et is None:
        raise Http404
    return render_to_response('emails/email_template_show.html', RequestContext(request, { 'et': et}))