def email_job_show(request,job_id): job = EMailJob.get_by_id(int(job_id)) if job is None: raise Http404 sub_list = EMailSubJob.all().ancestor(job) job_data = EMailJobData.all().ancestor(job).get() return render_to_response('emails/email_job_show.html', RequestContext(request, { 'sub_list': sub_list, 'job':job, 'job_data':job_data}))
def email_job_start(request,job_id): job = EMailJob.get_by_id(int(job_id)) if job is None: raise Http404 logging.info('starting mail job:%s'%job) if job.status != 'prepare': HttpResponse('ign') taskqueue.add(url='/tasks/start_email_job/%d/'%job.key().id(), method='GET') return redirect('..')
def email_job_start_task(request,job_id): job = EMailJob.get_by_id(int(job_id)) if job is None: raise Http404 logging.info('starting mail job:%s'%job) if job.status != 'prepare': HttpResponse('ign') sub_list = EMailSubJob.all().ancestor(job) for s in sub_list: logging.info('start: %s'%s) taskqueue.add(url='/tasks/fire_email_subjob/%s/'%s.key(), method='GET') logging.info('end') return HttpResponse('ok')
def email_job_prepare(request,job_id): job = EMailJob.get_by_id(int(job_id)) if job is None: raise Http404 logging.info('prepare mail job:%s'%job) if job.status != 'new': HttpResponse('ign') job_data = EMailJobData.all().ancestor(job).get() for i in range(0,len(job_data.emails),job_data.split_count): subjob = EMailSubJob(parent = job) subjob.emails_offset = i subjob.emails = job_data.emails[i:i+job_data.split_count] subjob.emails_count = len(subjob.emails) subjob.status = 'prepare' subjob.save() logging.info('subjob:%s'%subjob) job.status = 'prepare' job.save() return HttpResponse('ok')