@handle_response_format
@treeio_login_required
@_process_mass_form
def task_view(request, task_id, response_format='html'):
 task = get_object_or_404(Task, pk=task_id)
 if (not request.user.profile.has_permission(task)):
  return user_denied(request, message="You don't have access to this Task")
 if request.user.profile.has_permission(task, mode='x'):
  if request.POST:
   if ('add-work' in request.POST):
    return HttpResponseRedirect(reverse('projects_task_time_slot_add', args=[task.id]))
   elif ('start-work' in request.POST):
    return HttpResponseRedirect(reverse('projects_task_view', args=[task.id]))
   record = UpdateRecord()
   record.record_type = 'manual'
   form = TaskRecordForm(request.user.profile, request.POST, instance=record)
   if form.is_valid():
    record = form.save()
    record.set_user_from_request(request)
    record.save()
    record.about.add(task)
    task.set_last_updated()
    return HttpResponseRedirect(reverse('projects_task_view', args=[task.id]))
  else:
   form = TaskRecordForm(request.user.profile)
 else:
  form = None
 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, 'record_form': form, 'time_slots': time_slots})
 if (('massform' in context) and ('project' in context['massform'].fields)):
  del context['massform'].fields['project']
 return render_to_response('projects/task_view', context, context_instance=RequestContext(request), response_format=response_format)

@ handle_response_format @ treeio_login_required @ _process_mass_form def task_view ( request , task_id , response_format = 'html' ) : task = get_object_or_404 ( Task , pk = task_id ) if ( not request . user . profile . has_permission ( task ) ) : return user_denied ( request , message = "You don't have access to this Task" ) if request . user . profile . has_permission ( task , mode = 'x' ) : if request . POST : if ( 'add-work' in request . POST ) : return HttpResponseRedirect ( reverse ( 'projects_task_time_slot_add' , args = [ task . id ] ) ) elif ( 'start-work' in request . POST ) : return HttpResponseRedirect ( reverse ( 'projects_task_view' , args = [ task . id ] ) ) record = UpdateRecord ( ) record . record_type = 'manual' form = TaskRecordForm ( request . user . profile , request . POST , instance = record ) if form . is_valid ( ) : record = form . save ( ) record . set_user_from_request ( request ) record . save ( ) record . about . add ( task ) task . set_last_updated ( ) return HttpResponseRedirect ( reverse ( 'projects_task_view' , args = [ task . id ] ) ) else : form = TaskRecordForm ( request . user . profile ) else : form = None 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 , 'record_form' : form , 'time_slots' : time_slots } ) if ( ( 'massform' in context ) and ( 'project' in context [ 'massform' ] . fields ) ) : del context [ 'massform' ] . fields [ 'project' ] return render_to_response ( 'projects/task_view' , context , context_instance = RequestContext ( request ) , response_format = response_format )
decorator turning any task into a view that applies the task asynchronously .