def post(self, request): form = TaskForm(data=request.POST) if not form.is_valid(): return self.get(request, form) form.save() return redirect('index')
def add_task(request): # Get the context from the request. context = RequestContext(request) projectid = int(request.GET.get('projectid', '0')) context_dict = {} if request.method == 'POST': form = TaskForm(request.POST) # Have we been provided with a valid form? if form.is_valid(): # Save the new category to the database. form.save(commit=True) return HttpResponseRedirect('/project/view_tasks?projectid=' + str(projectid)) else: # The supplied form contained errors - just print them to the terminal. print form.errors else: # If the request was not a POST, display the form to enter details. form = TaskForm() context_dict["form"] = form context_dict["projectid"] = projectid # Bad form (or form details), no form supplied... # Render the form with error messages (if any). return render_to_response('webapp/add_requirement.html', context_dict, context)
def task_create(request, id): milestone = get_object_or_404(Milestone, pk=id) if request.method == 'POST': # If the form has been submitted... post = request.POST.copy() post['milestone']=milestone.id form = TaskForm(data=post) # A form bound to the POST data if form.is_valid(): # All validation rules pass form.save() # Process the data in form.cleaned_data # ... return redirect('/tasks') # Redirect after POST else: form = TaskForm( milestone=milestone, initial={ 'milestone': milestone, }, ) # An unbound form #from django import forms #form.depends_from = forms.ModelMultipleChoiceField(queryset=Task.objects.filter(milestone=milestone)) return render(request, 'task_create.html', { 'milestone': milestone, 'form': form, })
def update_task(request, id): task = Tasks.objects.get(pk=id) form = TaskForm(request.POST or None, instance=task) if request.POST: if form.is_valid(): form.save() return HttpResponseRedirect('/') else: return render(request, 'create_task.html', {'form': form})
def new_task(request): if request.method == 'POST': form = TaskForm(request.POST) if form.is_valid(): form.save() return HttpResponseRedirect('/') else: form = TaskForm() return render(request, 'create_task.html', {'form': form})
def get_task_list_task(request): t_l_id = None if request.method == 'POST': form = TaskForm(request.POST) if form.is_valid(): form.save() return HttpResponseRedirect('/new_task_list/') else: form = TaskForm() return render(request, "tasks_add.html", { 'form': form , 't_l_id':t_l_id})
def calendar(request): if request.method == "POST": c = Calendar.objects.all()[0] form = TaskForm(request.POST, Task()) if form.is_valid(): form.save() # create a new empty form form = TaskForm() else: form = TaskForm() return render_to_response("calendar.html", RequestContext(request, {"form": form}))
def addtask(request): if request.POST: form = TaskForm(request.POST) if form.is_valid(): form.save() messages.success(request, 'Task added!') return HttpResponseRedirect('/tasks/') else: form = TaskForm() return render(request, 'addtask.html', locals())
def post(self, request): form = TaskForm(request.POST) if form.is_valid(): form.save() messages.add_message(request, messages.INFO, "Task created!") return redirect("/list/%s/" % list_id) print form.errors context = {'form': form} return render(request, self.template_name, context)
def calendar(request): if request.method == 'POST': c = Calendar.objects.all()[0] form = TaskForm(request.POST, Task()) if form.is_valid(): form.save() # create a new empty form form = TaskForm() else: form = TaskForm() return render_to_response('calendar.html', RequestContext(request, {'form': form}))
def post(self, request, task_id): form = TaskForm(request.POST, instance=Task.objects.get(pk=task_id)) if form.is_valid(): form.save() messages.add_message(request, messages.INFO, "Task updated!") return redirect("/task/%s/" % task_id) print form.errors context = {'form': form} return render(request, self.template_name, context)
def task_form(request): context = RequestContext(request) if request.method == 'POST': form = TaskForm(request.POST) if form.is_valid(): form.save() return HttpResponseRedirect('/tasks/') else: print(form.errors) else: form = Task() return render_to_response('tasks/index.html', {'form': form}, context)
def edit_task(request, t_id): task = Task.objects.get(id=t_id) # instance ={'title':task.title,'body':task.body,'priority':task.priority } # form = EditTForm(initial={'title':task.title,'body':task.body,'priority':task.priority}) form = TaskForm(request.POST or None, instance= task) # form = TaskForm(initial={'title':instance.title,'body':instance.body,'priority':instance.priority,'dead_line':instance.dead_line,'note':instance.note,'pub_date':instance.pub_date}) if form.is_valid(): # task.title=form.cleaned_data['title'] # task.body=form.cleaned_data['body'] # task.priority=form.cleaned_data['priority'] form.save() return HttpResponseRedirect('/') return render(request,"task_edit.html",{'form':form})
def edit_task(request): task = Task.objects.get(id=request.POST.get('id')) copy = request.POST.copy() copy['user'] = request.user.id form = TaskForm(copy, instance=task) if form.is_valid(): form.save() messages.add_message(request, messages.SUCCESS, 'Task has been updated!') else: messages.add_message(request, messages.ERROR, 'Error: Task is not updated!') return HttpResponseRedirect(reverse('task:tasks'))
def todo(request): context = RequestContext(request) tasks = Task.objects.all if request.method == 'POST': form = TaskForm(request.POST) if form.is_valid(): form.save() return HttpResponseRedirect('/todo/') else: print(form.errors) else: form = Task() return render_to_response('tasks/TODO.html', {'tasks': tasks, 'form': form}, context)
def tasks(request): """Lists tasks""" if request.method == 'GET': order = request.GET.get('o', 'last_updated_on') results = Task.objects.filter(created_by=request.user).order_by(order) # Put in Pagination return render_to_response('tasks.html', {'tasks': results}, context_instance=RequestContext(request)) # post task = TaskForm(request.POST) if task.is_valid(): task.save() return HttpResponseRedirect('/task/%d'%task.id) return HttpResponse(status=400)
def ajax_task_edit(request, pk): """ Ajax call to edit a task. @param pk: the task's pk @return (in JSON format): {error: error message} if there's been an error {html: form html} if GET request or there are errors in the form {success: true} if the form was successfully submitted """ return_data = None try: # get task to edit task_to_edit = Task.objects.get(pk=pk) # check if user allowed to edit task if task_to_edit.user != request.user.get_profile(): raise Exception('You are not allowed to edit task %s.' % pk) # get form data form_data = None if request.method == 'POST': form_data = request.POST # create task form task_form = TaskForm(UserProfile=request.user.get_profile(), instance=task_to_edit, data=form_data) # check what to return if request.method == 'POST' and task_form.is_valid(): task_form.save() return_data = simplejson.dumps({'success': True,}) else: # create template context template_context = Context({ 'form': task_form, 'submit_value': 'Save changes', }) # add CSRF token to prevent errors from not using RequestContext template_context.update(csrf(request)) # get the form's html form_html = get_template('sussedical/_form.djhtml').render(template_context) return_data = simplejson.dumps({'html': form_html,}) except Exception as e: return_data = simplejson.dumps({'error': e.message,}) return HttpResponse(return_data, mimetype='application/javascript')
def create_task(request): if request.method == "POST": f = TaskForm(request.POST) if f.is_valid(): c = f.save(commit=False) c.CreatedOn = timezone.now() c.CreatedBy = request.user c.LastUpdatedOn = timezone.now() c.LastUpdatedBy = request.user c.save() messages.success(request, "Your Task was added") return HttpResponseRedirect('/persons/all') else: f = TaskForm() args = {} args.update(csrf(request)) args['form'] = f return render_to_response('create_task.html', args) message.add_message(request, settings.DELETE_MESSAGE, "Your task was deleted successfully") return HttpResponseRedirect('/persons/all' % person_id)
def edit_task_in_list(request, storyID, taskID): story = mdl_story.get_story(storyID) task = mdl_task.get_task(taskID) project = story.project association = UserAssociation.objects.get( user=request.user, project=project) if request.method == 'POST': form = TaskForm(request.POST, instance=task) if form.is_valid(): task = form.save(commit=True) else: form = TaskForm(instance=task) tasks = mdl_task.get_tasks_for_story(story) context = { 'story': story, 'tasks': tasks, 'task': task, 'editform': form, 'project': project, 'association': association } return render(request, 'TaskList.html', context)
def task_add_subtask(request, task_id=None, response_format='html'): """New subtask form""" parent = None if task_id: parent = get_object_or_404(Task, pk=task_id) if not request.user.profile.has_permission(parent, mode='x'): parent = None if request.POST: if 'cancel' not in request.POST: task = Task() form = TaskForm( request.user.profile, parent, None, None, request.POST, instance=task) if form.is_valid(): task = form.save() task.set_user_from_request(request) return HttpResponseRedirect(reverse('projects_task_view', args=[parent.id])) else: return HttpResponseRedirect(reverse('projects_task_view', args=[parent.id])) else: form = TaskForm(request.user.profile, parent, None, None) context = _get_default_context(request) context.update({'form': form, 'task': parent}) return render_to_response('projects/task_add_subtask', context, context_instance=RequestContext(request), response_format=response_format)
def test_task_form(self): data = { "title": "Write some tests", "day": "01/04/2005", "start_time": 2, "end_time": 2, "user": self.alice.pk, "project": self.project.pk, "status": Project.ACTIVE, "task_type": self.et.pk, } form = TaskForm(data) self.assertFalse(form.is_valid()) data["start_time"] = 11 data["count"] = 3 form = TaskForm(data) self.assert_(form.is_valid()) tt = TaskType.objects.create(title="why?") task = form.save(commit=False) task.task_type = tt task.author = self.alice task.save() task.add_occurrences( form.cleaned_data["start_time"], form.cleaned_data["end_time"], count=form.cleaned_data["count"] ) self.assertEqual(Occurrence.objects.count(), 3)
def edit_task_in_list(request, storyID, taskID): story = mdl_story.get_story(storyID) task = mdl_task.get_task(taskID) project = story.project association = UserAssociation.objects.get( user=request.user, project=project ) if request.method == 'POST': form = TaskForm(request.POST, instance=task) if form.is_valid(): task = form.save(commit=True) else: form = TaskForm(instance=task) tasks = mdl_task.get_tasks_for_story(story) context = { 'story': story, 'tasks': tasks, 'task': task, 'editform': form, 'project': project, 'association': association } return render(request, 'TaskList.html', context)
def task_edit(request, task_id, response_format='html'): """Task edit page""" task = get_object_or_404(Task, pk=task_id) if not request.user.profile.has_permission(task, mode='w'): return user_denied(request, message="You don't have access to this Task") if request.POST: if 'cancel' not in request.POST: form = TaskForm( request.user.profile, None, None, None, request.POST, instance=task) if form.is_valid(): task = form.save() return HttpResponseRedirect(reverse('projects_task_view', args=[task.id])) else: return HttpResponseRedirect(reverse('projects_task_view', args=[task.id])) else: form = TaskForm( request.user.profile, None, None, None, instance=task) context = _get_default_context(request) context.update({'form': form, 'task': task}) return render_to_response('projects/task_edit', context, context_instance=RequestContext(request), response_format=response_format)
def create_subtask(request, task_id): parent = Task.objects.get(id=task_id) pr = Project.objects.get(id=parent.project_id) if request.method == 'POST': form = TaskForm(request.POST, request.FILES) if form.is_valid(): c = form.save(commit=False) c.creator = auth.get_user(request) c.project = pr c.parent_task = parent c.save() form.save_m2m() task = Task.objects.get(id=c.id) assign_newtask_perm(task, pr, request.user) loger(auth.get_user(request), 'task_created', c.name, c, pr) return HttpResponseRedirect('/projector/project/{}'.format(parent.project_id)) else: form = TaskForm() args = {} args.update(csrf(request)) args['project'] = pr args['form'] = form args['parent'] = parent args['username'] = auth.get_user(request).username # import pdb; pdb.set_trace() return render_to_response('create_task.html',args)
def edit(request, task=None): args = {} if task: args['instance'] = get_object_or_404(Task, pk=task, user=request.user) else: args['user'] = request.user print task if request.POST: form = TaskForm(request.POST, **args) if form.is_valid(): form.save() return HttpResponse('') else: form = TaskForm(**args) return render_to_response('edit.html', {'form': form}, context_instance=RequestContext(request))
def edit_task(request,id): task = get_object_or_404( Task, pk=id ) if 'POST' == request.method: form = TaskForm( request.POST, instance = task ) if form.is_valid(): form.save() request.notifications.success('Task Updated' ) return HttpResponseRedirect( reverse('list_tasks') ) else: form = TaskForm(instance = task) return render(request,'formpage.html', { 'title' : 'Edit Task', 'form' : form })
def task_add_to_milestone(request, milestone_id=None, response_format='html'): """Task add to preselected project""" milestone = None if milestone_id: milestone = get_object_or_404(Milestone, pk=milestone_id) if not request.user.profile.has_permission(milestone, mode='x'): milestone = None project = milestone.project project_id = milestone.project.id if request.POST: if 'cancel' not in request.POST: task = Task() form = TaskForm(request.user.profile, None, project_id, milestone_id, request.POST, instance=task) if form.is_valid(): task = form.save() task.set_user_from_request(request) return HttpResponseRedirect(reverse('projects_task_view', args=[task.id])) else: return HttpResponseRedirect(reverse('projects_milestone_view', args=[milestone.id])) else: form = TaskForm( request.user.profile, None, project_id, milestone_id) context = _get_default_context(request) context.update({'form': form, 'project': project, 'milestone': milestone}) return render_to_response('projects/task_add_to_milestone', context, context_instance=RequestContext(request), response_format=response_format)
def list_view(request): if request.method == "GET": form = TaskForm() elif request.method == "POST": form = TaskForm(request.POST) if form.is_valid(): form.save() # make sure to return use a clean form for the resulting page form = TaskForm() else: raise PermissionDenied('Only GET and POST methods are allowed') return render(request, 'todolist/list-view.html', { 'tasks': Task.objects.all(), 'form': form })
def add_task(request): """Adds a task.""" if request.method == "POST": form = TaskForm(request.POST) if form.is_valid(): form.save() return redirect('list-tasks', 'view', 'today') else: form = TaskForm() return render(request, 'add_task.html', { 'contexts': Context.objects.all(), 'form': form, 'menu': 'new_task', 'projects': Project.objects.all(), 'task_count': get_task_count(), })
def edit(request, id=None): if id is not None: task = get_object_or_404(SpecialQuestTask, pk=id) else: task = None form = TaskForm(instance=task) if request.method == 'POST': form = TaskForm(request.POST, instance=task) if form.is_valid(): form.save() return HttpResponseRedirect(reverse('wouso.games.specialquest.cpanel.home')) return render_to_response('specialquest/cpanel_edit.html', {'task': task, 'form': form, 'module': 'specialquest'}, context_instance=RequestContext(request))
def edit(request, id=None): if id is not None: task = get_object_or_404(SpecialQuestTask, pk=id) else: task = None form = TaskForm(instance=task) if request.method == "POST": form = TaskForm(request.POST, instance=task) if form.is_valid(): form.save() return HttpResponseRedirect(reverse("wouso.games.specialquest.cpanel.home")) return render_to_response( "specialquest/cpanel_edit.html", {"task": task, "form": form, "module": "specialquest"}, context_instance=RequestContext(request), )
def update(request, project_slug, task_id): project = Project.get_by_slug(request.user, project_slug) task = get_object_or_404(Task, pk=task_id, project=project) form = TaskForm(request.POST, instance=task) if form.is_valid(): task = form.save() tre = TaskRegexp() due_date = tre.get_date(task.title) task.due_date = due_date task.save() return HttpResponse(dumps(dict(html=task.html)))
def edittask(request, task_id): task = get_object_or_404(Task, pk=task_id) volunteers = Task.objects.filter(volunteers=task_id) t = "Edit" if request.POST: form = TaskForm(request.POST, instance=task) if form.is_valid(): form.save() messages.success(request, 'Updated!') return HttpResponseRedirect('/schedule/') else: form = TaskForm(instance=task) return render_to_response("edittask.html", { 'form': form, 't': t, 'task': task, 'volunteers': volunteers, }, context_instance=RequestContext(request))
def edit_task_in_list(request, storyID, taskID): story = mdl_story.get_story(storyID) task = mdl_task.get_task(taskID) if request.method == 'POST': form = TaskForm(request.POST, instance=task) if form.is_valid(): task = form.save(commit=True) else: form = TaskForm(instance=task) tasks = mdl_task.get_tasks_for_story(story) context = { 'story': story, 'tasks': tasks, 'task': task, 'editform': form, } return render(request, 'TaskList.html', context)
def edit_task(request, bid=None, tid=None): """ Edit/GET and save/POST a task entity for a backlog item. User permission required: add_backlog """ if tid: task = get_object_or_404(Task, pk=tid) backlog = task.item elif bid: backlog = get_object_or_404(Backlog, pk=bid) task = None if request.method == 'POST': form = TaskForm(request.POST, instance=task) if form.is_valid(): tsk = form.save(commit=False) if not hasattr(tsk, 'item'): setattr(tsk, 'item', backlog) try: tsk.save() #form.save_m2m() except Exception, e: logger.error('edit_task form.save failure %s' % e) return HttpResponseRedirect('/backlog/%s/tasks' % backlog.pk)
def save(request): rank = None sid = request.POST.get('id') start = request.POST.get('start', 0) end = request.POST.get('end', 0) if int(start) > int(end): result = {"ret": 10000, "status": "failed", "msg": "评论间隔的开始时间不能大于结束时间"} return HttpResponse(json.dumps(result), content_type="application/json") try: if sid: rank = Task.objects.get(id=sid) if rank.sync_flag == 1: result = { "ret": 10000, "status": "failed", "msg": "任务已分配,无法进行修改!" } return HttpResponse(json.dumps(result), content_type="application/json") except Task.DoesNotExist: pass if rank: option = request.POST.get("option") # if int(option): # accounts = Account.objects.filter(delflag=0, tag_id=request.POST.get('tag'), createuser_id=5) # if accounts.count() == 0: # result = {"ret": 10000, "status": "failed", "msg": "当前系统下没有买手号,请联系客服!"} # return HttpResponse(json.dumps(result), content_type="application/json") # integral = 100 # else: # accounts = Account.objects.filter(delflag=0, tag_id=request.POST.get('tag'), createuser_id=request.user.id,enable_review=0) # if accounts.count() == 0: # result = {"ret": 10000, "status": "failed", "msg": "当前账号下没有买手号!"} # return HttpResponse(json.dumps(result), content_type="application/json") form = TaskForm(request.POST or None, instance=rank) else: option = request.POST.get("option") comment = request.POST.get( "comment" ) #.replace('∣', '|').replace("‘", "'").replace(',', ',').replace('|', '|') comments = comment.strip().strip('\r\n').split('\r\n') for com in comments: coms = com.split('|') if len(coms) != 2: result = { "ret": 10000, "status": "failed", "msg": "请输入正确的评论格式(标点符号为英文符号),错误的评论为:%s" % com } return HttpResponse(json.dumps(result), content_type="application/json") total = request.POST.get('total') if int(total) > len(comments): result = { "ret": 10000, "status": "failed", "msg": "输入的评论总数大于设置的评论条数!" } return HttpResponse(json.dumps(result), content_type="application/json") # if int(option): # accounts = Account.objects.filter(delflag=0, tag_id=request.POST.get('tag'), createuser_id=5,enable_review=0) # if accounts.count() == 0: # result = {"ret": 10000, "status": "failed", "msg": "当前系统下没有买手号,请联系客服!"} # return HttpResponse(json.dumps(result), content_type="application/json") integral = 100 # else: # accounts = Account.objects.filter(delflag=0, tag_id=request.POST.get('tag'), createuser_id=request.user.id) # if accounts.count() == 0: # result = {"ret": 10000, "status": "failed", "msg": "当前账号下没有买手号!"} # return HttpResponse(json.dumps(result), content_type="application/json") # discount = request.user.user_profile.discount # integral = int(30 * (discount / 100.0)) total_integral = integral * len(comments) if Profile.objects.get( user_id=request.user.id).integral < total_integral: result = {"ret": 10000, "status": "failed", "msg": "当前账号积分不足!"} return HttpResponse(json.dumps(result), content_type="application/json") form = TaskForm(request.POST or None) if form.is_valid(): instance = form.save(commit=False) instance.start = start instance.end = end if sid: instance.updateuser = request.user else: instance.createuser = request.user instance.save() # if sid: # Log.objects.create(user_id=request.user.id, ctype=2, operation=1, desc=u"修改标签:" + name) # else: # Log.objects.create(user_id=request.user.id, ctype=2, operation=0, desc=u"新增标签:" + name) result = {"ret": 0, "status": "success"} return HttpResponse(json.dumps(result), content_type="application/json") else: msg = [] if form.errors: for k, v in form.errors.iteritems(): msg.append(v[0]) return HttpResponse(json.dumps({ "ret": 10000, "status": "error", "msg": '\n'.join(msg) }), content_type="application/json")
def edit_task (request, task_id = None, owner_name = None): """ Edit existing Task. TODO : Do user validation (should have permission) Allow delete Task facility (?) Cancel Edit Save Draft """ page_owner = get_page_owner (request, owner_name) user = request.user dept_names = [name for name, description in DEP_CHOICES] if task_id: # Existing Task curr_task = Task.objects.get (id = task_id) is_new_task = False else: # New Task curr_task = Task (creator = user) is_new_task = True # curr_object = Task.objects.get (id = task_id) is_task_comment = True other_errors = False SubTaskFormSet = inlineformset_factory (Task, SubTask, form = SubTaskForm, exclude = subtask_exclusion_tuple, extra = 0, can_delete = True) if request.method == 'POST': # Get the submitted formset subtaskfs = SubTaskFormSet (request.POST, instance = curr_task) template_form = subtaskfs.empty_form task_form = TaskForm (request.POST, instance = curr_task) if task_form.is_valid () and subtaskfs.is_valid (): curr_task = task_form.save (commit = False) curr_task.save() print 'Task : ', curr_task comments, comment_form, comment_status = handle_comment ( request = request, is_task_comment = True, object_id = task_id) # Only the filled forms will be stored in subtasks # Also, subtasks marked for deletion are deleted here. subtasks = subtaskfs.save (commit = False) for subtask in subtasks: print 'Subtask : ', subtask subtask.creator = user subtask.status = DEFAULT_STATUS # In case it's a new form (inline formset won't # fill in the task in that case) subtask.task = curr_task subtask.save () subtaskfs.save_m2m () # Necessary, since we used commit = False return redirect ('erp.tasks.views.display_portal', owner_name = owner_name) else: # One or more Forms are invalid other_errors = True else: task_form = TaskForm (instance = curr_task) subtaskfs = SubTaskFormSet (instance = curr_task) template_form = subtaskfs.empty_form comments, comment_form, comment_status = handle_comment ( request = request, is_task_comment = True, object_id = task_id, other_errors = other_errors) return render_to_response('tasks/edit_task.html', locals(), context_instance = global_context (request))
def edit_task(request, task_id=None, owner_name=None): """ Edit existing Task. TODO : Do user validation (should have permission) Allow delete Task facility (?) Cancel Edit Save Draft """ page_owner = get_page_owner(request, owner_name) user = request.user if task_id: # Existing Task curr_task = Task.objects.get(id=task_id) is_new_task = False else: # New Task curr_task = Task(creator=user) is_new_task = True other_errors = False task_doc_status = 'OK' # Simple test for autocomplete feature subject_data = [] for task in Task.objects.all(): subject_data.append(task.subject) # print 'Subject data : ', subject_data subject_data_js = simplejson.dumps(subject_data) SubTaskFormSet = inlineformset_factory(Task, SubTask, form=SubTaskForm, exclude=subtask_exclusion_tuple, extra=0, can_delete=True) # TagFormSet = modelformset_factory (Tag, extra = 1, can_delete = True, # exclude = ('task',)) # subtask_comments = [] if request.method == 'POST': # Get the submitted formset subtaskfs = SubTaskFormSet(request.POST, instance=curr_task) template_form = subtaskfs.empty_form task_form = TaskForm(request.POST, instance=curr_task) if task_form.is_valid() and subtaskfs.is_valid(): # if not is_new_task: # tdfs, task_doc_status = handle_task_documents ( # request, owner_name, task_id, other_errors, only_validity = True) # if task_doc_status != 'Invalid': curr_task = task_form.save(commit=False) curr_task.save() print 'Task : ', curr_task comments, comment_form, comment_status = handle_comment( request=request, is_task_comment=True, object_id=task_id) # tagfs = TagFormSet (request.POST) # if tagfs.is_valid (): # tags = tagfs.save (commit = False) # for tag in tags: # tag.save () # tag.task.add (curr_task) # tagfs.save_m2m () # Necessary, since we used commit = False # st_comment_list = [handle_comment (request, False, form.instance.id) for form in subtaskfs] # if not is_new_task: tdfs, task_doc_status = handle_task_documents( request, owner_name, curr_task.id, other_errors=other_errors) # Only the filled forms will be stored in subtasks # Also, subtasks marked for deletion are deleted here. subtasks = subtaskfs.save(commit=False) for subtask in subtasks: print 'Subtask : ', subtask subtask.creator = user subtask.status = DEFAULT_STATUS # In case it's a new form (inline formset won't # fill in the task in that case) subtask.task = curr_task subtask.save() subtaskfs.save_m2m() # Necessary, since we used commit = False return redirect('tasks.views.display_portal', owner_name=owner_name) else: # One or more Forms are invalid other_errors = True else: task_form = TaskForm(instance=curr_task) subtaskfs = SubTaskFormSet(instance=curr_task) template_form = subtaskfs.empty_form print 'Template Form : ', template_form # if not is_new_task and task_doc_status != 'Invalid': tdfs, task_doc_status = handle_task_documents(request, owner_name, task_id, other_errors) # tagfs = TagFormSet (queryset = Tag.objects.filter (task__id = task_id)) comments, comment_form, comment_status = handle_comment( request=request, is_task_comment=True, object_id=task_id, other_errors=other_errors) return render_to_response('tasks/edit_task.html', locals(), context_instance=global_context(request))