@handle_response_format
@treeio_login_required
def task_add(request, response_format='html'):
 if request.POST:
  if ('cancel' not in request.POST):
   task = Task()
   form = TaskForm(request.user.profile, None, 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=[task.id]))
  else:
   return HttpResponseRedirect(reverse('projects'))
 else:
  form = TaskForm(request.user.profile, None, None, None)
 context = _get_default_context(request)
 context.update({'form': form})
 return render_to_response('projects/task_add', context, context_instance=RequestContext(request), response_format=response_format)

@ handle_response_format @ treeio_login_required def task_add ( request , response_format = 'html' ) : if request . POST : if ( 'cancel' not in request . POST ) : task = Task ( ) form = TaskForm ( request . user . profile , None , 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 = [ task . id ] ) ) else : return HttpResponseRedirect ( reverse ( 'projects' ) ) else : form = TaskForm ( request . user . profile , None , None , None ) context = _get_default_context ( request ) context . update ( { 'form' : form } ) return render_to_response ( 'projects/task_add' , context , context_instance = RequestContext ( request ) , response_format = response_format )
new task form .