Exemplo n.º 1
0
 def wm_import_job(self):
   for job in Job.objects.all():
     job.delete()
   wm_jobs = WorkflowmaxJob.objects.all(datetime.now() - timedelta(days=365), datetime.now() + timedelta(days=365))
   for wm_job in wm_jobs:
     job = Job()
     job.wm_import(wm_job)
Exemplo n.º 2
0
def import_jobs(request):
  context_vars = dict()
  context_vars['header'] = capfirst(_('import jobs from workflowmax'))
  context_vars['comment'] = capfirst(_('this will destroy all your local jobs, please confirm your decision.'))
  if request.method == "POST":
    try:
      for job in Job.objects.all():
        job.delete()
      wm_jobs = WorkflowmaxJob.objects.all(datetime.now() - timedelta(days=365), datetime.now() + timedelta(days=365))
  #    wm_jobs = WorkflowmaxJob.objects.current()
      for wm_job in wm_jobs:
        job = Job()
        job.wm_import(wm_job)
      messages.success(request, capfirst(_('jobs were imported successfully')), fail_silently=True)
      return HttpResponseRedirect(reverse('job-list'))
    except NoInitialData, e:
      context_vars['error'] = capfirst(e)