Exemplo n.º 1
0
def add_milestone(request, object_id):
  context_vars = dict()
  try:
    object_id = int(object_id)
    job = Job.objects.get(id=object_id)
  except ValueError:
    return HttpResponseRedirect(reverse('job-list'))
  except ObjectDoesNotExist:
    return HttpResponseRedirect(reverse('job-list'))

  form = MilestoneForm()
  helper = FormHelper()
  submit = Submit('save',_('save'))
  helper.add_input(submit)
  
  if request.method == "POST":
    form = MilestoneForm(request.POST, request.FILES)
    if form.is_valid():
      milestone = form.save(commit=False)
      milestone.job = job
      milestone.save()
#      if settings.WORKFLOWMAX_APIKEY and settings.WORKFLOWMAX_ACCOUNTKEY:
#        milestone.wm_sync()
      messages.success(request, capfirst(_('milestone was added successfully')), fail_silently=True)
      return HttpResponseRedirect(reverse('job-view', args=[job.id]))
  
  context_vars['form'] = form
  context_vars['helper'] = helper
  return direct_to_template(request, template='job/uniform.html', extra_context=context_vars)  
Exemplo n.º 2
0
def edit_milestone(request, owner_id, object_id):
  context_vars = dict()
  try:
    owner_id = int(owner_id)
    job = Job.objects.get(id=owner_id)
  except ValueError:
    return HttpResponseRedirect(reverse('job-list'))
  except ObjectDoesNotExist:
    return HttpResponseRedirect(reverse('job-list'))
  try:
    object_id = int(object_id)
    milestone = Milestone.objects.get(id=object_id)
  except ValueError, ObjectDoesNotExist:
    return HttpResponseRedirect(reverse('job-view', args=[job.id]))

  form = MilestoneForm(instance=milestone)
  helper = FormHelper()
  submit = Submit('save',_('save'))
  helper.add_input(submit)
  
  if request.method == "POST":
    form = MilestoneForm(request.POST, request.FILES, instance=milestone)
    if form.is_valid():
      form.save()
#      if settings.WORKFLOWMAX_APIKEY and settings.WORKFLOWMAX_ACCOUNTKEY:
#        milestone.wm_sync()
      messages.success(request, capfirst(_('milestone was modified successfully')), fail_silently=True)
      return HttpResponseRedirect(reverse('job-view', args=[job.id]))
  
  context_vars['form'] = form
  context_vars['helper'] = helper