def wm_sync(self): if self.wm_id and self.job.wm_id and self.name: wm_task = WorkflowmaxTask() wm_task.id = int(self.wm_id) wm_task.owner_id = self.job.wm_id wm_task.name = self.name wm_task.description = self.description wm_task.estimated_minutes = self.estimated_minutes wm_task.save()
def edit_job_task(request, owner_id, object_id): try: object_id = int(object_id) except ValueError: return HttpResponseRedirect(reverse('workflowmax-job', args=[owner_id])) context_vars = dict() context_vars['header'] = capfirst(_('edit task %d') % object_id) # task = Task.objects.get(id=object_id) job = Job.objects.get(id=owner_id) for task_obj in job.tasks: if task_obj.id == object_id: task = task_obj if not task: return HttpResponseRedirect(reverse('workflowmax-job', args=[owner_id])) task = Task(xml_object=task) form = TaskForm(task.to_dict()) helper = FormHelper() submit = Submit('save',_('save')) helper.add_input(submit) if request.method == "POST": form = TaskForm(request.POST, request.FILES) if form.is_valid(): task.owner_id = job.id task.name = form.cleaned_data['name'] task.description = form.cleaned_data['description'] task.estimated_minutes = form.cleaned_data['estimated_minutes'] # task.actual_minutes = form.cleaned_data['actual_minutes'] # task.completed = form.cleaned_data['completed'] # task.billable = form.cleaned_data['billable'] # task.start_date = form.cleaned_data['start_date'] # task.due_date = form.cleaned_data['due_date'] # task.completed = form.cleaned_data['completed'] # if form.cleaned_data['assigned']: # task.assigned = [] # for assigned_id in form.cleaned_data['assigned']: # try: # task.assigned.append(Staff.objects.get(id=assigned_id)) # except ResponseStatusError: # pass task.save() return HttpResponseRedirect(reverse('workflowmax-job', args=[owner_id])) context_vars['form'] = form context_vars['helper'] = helper return direct_to_template(request, template='workflowmax/form.html', extra_context=context_vars)