@handle_response_format
@treeio_login_required
def task_delete(request, task_id, response_format='html'):
 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 ('delete' in request.POST):
   if ('trash' in request.POST):
    task.trash = True
    task.save()
   else:
    task.delete()
   return HttpResponseRedirect(reverse('projects_index'))
  elif ('cancel' in request.POST):
   return HttpResponseRedirect(reverse('projects_task_view', args=[task.id]))
 subtasks = Object.filter_by_request(request, Task.objects.filter(parent=task))
 time_slots = Object.filter_by_request(request, TaskTimeSlot.objects.filter(task=task))
 context = _get_default_context(request)
 context.update({'task': task, 'subtasks': subtasks, 'time_slots': time_slots})
 return render_to_response('projects/task_delete', context, context_instance=RequestContext(request), response_format=response_format)

@ handle_response_format @ treeio_login_required def task_delete ( request , task_id , response_format = 'html' ) : 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 ( 'delete' in request . POST ) : if ( 'trash' in request . POST ) : task . trash = True task . save ( ) else : task . delete ( ) return HttpResponseRedirect ( reverse ( 'projects_index' ) ) elif ( 'cancel' in request . POST ) : return HttpResponseRedirect ( reverse ( 'projects_task_view' , args = [ task . id ] ) ) subtasks = Object . filter_by_request ( request , Task . objects . filter ( parent = task ) ) time_slots = Object . filter_by_request ( request , TaskTimeSlot . objects . filter ( task = task ) ) context = _get_default_context ( request ) context . update ( { 'task' : task , 'subtasks' : subtasks , 'time_slots' : time_slots } ) return render_to_response ( 'projects/task_delete' , context , context_instance = RequestContext ( request ) , response_format = response_format )
delete a task object .