@handle_response_format
@treeio_login_required
def agent_edit(request, agent_id, response_format='html'):
 view_agent = get_object_or_404(ServiceAgent, pk=agent_id)
 if (not request.user.profile.has_permission(view_agent)):
  return user_denied(request, message="You don't have access to this Service Agent")
 if request.POST:
  if ('cancel' not in request.POST):
   form = AgentForm(request.user.profile, request.POST, instance=view_agent)
   if form.is_valid():
    view_agent = form.save()
    return HttpResponseRedirect(reverse('services_agent_view', args=[view_agent.id]))
  else:
   return HttpResponseRedirect(reverse('services_agent_view', args=[view_agent.id]))
 else:
  form = AgentForm(request.user.profile, instance=view_agent)
 context = _get_default_context(request)
 context.update({'form': form, 'view_agent': view_agent})
 return render_to_response('services/agent_edit', context, context_instance=RequestContext(request), response_format=response_format)

@ handle_response_format @ treeio_login_required def agent_edit ( request , agent_id , response_format = 'html' ) : view_agent = get_object_or_404 ( ServiceAgent , pk = agent_id ) if ( not request . user . profile . has_permission ( view_agent ) ) : return user_denied ( request , message = "You don't have access to this Service Agent" ) if request . POST : if ( 'cancel' not in request . POST ) : form = AgentForm ( request . user . profile , request . POST , instance = view_agent ) if form . is_valid ( ) : view_agent = form . save ( ) return HttpResponseRedirect ( reverse ( 'services_agent_view' , args = [ view_agent . id ] ) ) else : return HttpResponseRedirect ( reverse ( 'services_agent_view' , args = [ view_agent . id ] ) ) else : form = AgentForm ( request . user . profile , instance = view_agent ) context = _get_default_context ( request ) context . update ( { 'form' : form , 'view_agent' : view_agent } ) return render_to_response ( 'services/agent_edit' , context , context_instance = RequestContext ( request ) , response_format = response_format )
agent edit .