Пример #1
0
def job_save(request):
    if request.POST:
      form = add_job_form(request.POST)
      Job = form.save(request.POST)
      f = open('%s/%s' %(settings.SCRIPTS_DIR,Job.name) , 'w')
      myfile = File(f)
      content = '#!/bin/sh \nRecips=" %s " \nSubj=" %s " \nBody="%s" \nFromDir="%s" \n source sys/mailer.sh \n ' % ( Job.recips , Job.subj, Job.body ,Job.fromdir )
      myfile.write(content)
      f.close()
      myfile.close()
      os.chmod('%s/%s' %(settings.SCRIPTS_DIR,Job.name),stat.S_IRWXU)
      return redirect ('/mailer/viewjob/')
Пример #2
0
def job_save_e(request,job_id):
    if request.POST:
      a = Job.objects.get(id=job_id)
      os.remove('/scripts/%s' %(a.name))
      form = add_job_form(request.POST,instance=a)
      job = form.save(request.POST)
      f = open('%s/%s' %(settings.SCRIPTS_DIR,a.name), 'w')
      myfile = File(f)
      content = '#!/bin/sh \nRecips=" %s " \nSubj=" %s " \nBody="%s" \nFromDir="%s" \n source sys/mailer.sh \n  ' % ( a.recips , a.subj, a.body ,a.fromdir )
      myfile.write(content)
      f.close()
      myfile.close()
      os.chmod('%s/%s' %(settings.SCRIPTS_DIR,a.name),stat.S_IRWXU)
      return redirect ('/mailer/viewjob/')
Пример #3
0
def job_edit(request,job_id):
    a = add_job_form( initial={
    'name' :Job.objects.get(id=job_id).name ,
    'recips' :Job.objects.get(id=job_id).recips ,
    'subj' :Job.objects.get(id=job_id).subj,
    'body' :Job.objects.get(id=job_id).body,
    'fromdir' :Job.objects.get(id=job_id).fromdir
    },)
    args = {}
    args.update(csrf(request))
    args['form'] = a
    args['jobs'] = Job.objects.all()
    args['job_id'] = job_id
    args['job_name'] = Job.objects.get(id=job_id).name
    rc = RequestContext(request, args)
    return render_to_response("jobform.html",rc)