Ejemplo n.º 1
0
def email_job_create(request):
    email_groups = EMailList.all()
    email_templates = EMailTemplate.all()


    if request.method == 'POST':
        form = EMailJobCreateForm(request.POST,email_groups=email_groups, email_templates=email_templates)
        if form.is_valid():
            logging.info('creating new job request')
            el = EMailList.get(form.cleaned_data['email_group_id'])
            if el is None:
                raise Http404
            et = EMailTemplate.get(form.cleaned_data['email_template_id'])
            if et is None:
                raise Http404

            job = EMailJob()
            job.name = "'%s' -> '%s'"%(et.name,el.name)
            job.save()

            job_data = EMailJobData(parent=job)             
            job_data.sender = getConfig('DEFAULT_SENDER')
            job_data.split_count = getConfigInt('MAIL_SPLIT_COUNT',10)
            job_data.emails = el.emails
            job_data.data =  et.data

            job_data.save()
            job.data_ref = job_data.key()
            job.save()

            logging.info('new job: %s'%job)

            taskqueue.add(url='/tasks/prepare_email_job/%d/'%job.key().id(), method='GET')

            return redirect('..')
    else:
        form = EMailJobCreateForm(email_groups=email_groups, email_templates=email_templates)

    return render_to_response('emails/email_job_create.html', RequestContext(request, { 'form': form}))
Ejemplo n.º 2
0
def emailGroupCreate(request):
    if request.method == 'POST':
        form = EMailGroupForm(request.POST)
        if form.is_valid():
            el = EMailList()
            el.name = form.cleaned_data['name']
            el.desc = form.cleaned_data['desc']
            el.emailsFromString(form.cleaned_data['emails'])
            el.save()
            return redirect('..')
    else:
        form = EMailGroupForm()
 
    return render_to_response('emails/emailGroup.html', RequestContext(request, { 'form' : form }))
Ejemplo n.º 3
0
def emailGroupEdit(request, emailGroupId):
    el = EMailList.get_by_id(int(emailGroupId))
    if el  is None:
        raise Http404
    
    if request.method == 'POST':
        form = EMailGroupForm(request.POST)
        if form.is_valid():
            el.name = form.cleaned_data['name']
            el.desc = form.cleaned_data['desc']
            el.emailsFromString(form.cleaned_data['emails'])
            el.save()
            return redirect('../..')
    else:
        data = {'name':el.name, 'desc':el.desc, 'emails':el.emailsAsString()}
        form = EMailGroupForm(data)
    return render_to_response('emails/emailGroup.html', RequestContext(request, { 'form' : form}))
Ejemplo n.º 4
0
def emailGroupShow(request, emailGroupId):
    el = EMailList.get_by_id(int(emailGroupId))
    if el  is None:
        raise Http404
    return render_to_response('emails/emailGroup.html', RequestContext(request, { 'el': el}))