def multi_send(request, et_id): et = EMailTemplate.get_by_id(int(et_id)) if et is None: raise Http404 if not et.valid: raise Http404 if request.method == 'POST': form = EMailMultiForm(request.POST) if form.is_valid(): el = form.cleaned_data['emails'] els = list(el.split()) els_c = len(els) logging.info('list size %d'%(els_c)) if els_c > 0: ej = EMailJob() ej.setData(els,et.data) ej.save() plan_send_multimail(els,ej.key().id()) return redirect('../..') else: form = EMailMultiForm() return render_to_response('admin/emailtemplate_multisend.html', RequestContext(request, { 'form': form, 'et':et }) )
def test_send(request, et_id): et = EMailTemplate.get_by_id(int(et_id)) if et is None: raise Http404 if request.method == 'POST': form = EMailTestForm(request.POST) if form.is_valid(): try: email = EmailMessage(et.data) email.sender = cfg.getConfigString('ENROLL_EMAIL',None) email.reply_to = cfg.getConfigString('ENROLL_REPLY_TO',None) email.to = form.cleaned_data['email'] email.check_initialized() logging.info('sending...') email.send() logging.info('send ok') et.valid = True et.save() except: logging.info("can't init/send email! %s"%sys.exc_info()[1]) return HttpResponse("can't init/send email - %s"%sys.exc_info()[1]) return redirect('../..') else: form = EMailTestForm() return render_to_response('admin/emailtemplate_testsend.html', RequestContext(request, { 'form': form, 'et':et }) )
def delete(request, et_id): et = EMailTemplate.get_by_id(int(et_id)) if et is None: raise Http404 et.delete() return redirect('../..')
def edit(request, et_id): et = EMailTemplate.get_by_id(int(et_id)) if et is None: raise Http404 if request.method == 'POST': form = EMailTemplateForm(request.POST, instance=et) if form.is_valid(): logging.info('edit el before - %s' % (et)) form.save(commit=False) logging.info('edit el after - %s' % (et)) et.save() return redirect('../..') else: form = EMailTemplateForm(instance=et) return render_to_response('admin/emailtemplate_edit.html', RequestContext(request, { 'form': form }) )
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 et.locked: logging.info('template is locked') return et.setData(data) et.save() logging.info('template updated and closed')
def show(request, et_id): et = EMailTemplate.get_by_id(int(et_id)) if et is None: raise Http404 return render_to_response('admin/emailtemplate_show.html', RequestContext(request, { 'et': et }))
def index(request): ets = EMailTemplate.list_all() return render_to_response('admin/emailtemplate_index.html', RequestContext(request, { 'list': ets }))