@treeio_login_required
@handle_response_format
def lead_edit(request, lead_id, response_format='html'):
 lead = get_object_or_404(Lead, pk=lead_id)
 if ((not request.user.profile.has_permission(lead, mode='w')) and (not request.user.profile.is_admin('treeio.sales'))):
  return user_denied(request, "You don't have access to this Lead", response_format)
 if request.POST:
  form = LeadForm(request.user.profile, request.POST, instance=lead)
 else:
  form = LeadForm(request.user.profile, instance=lead)
 if form.is_valid():
  lead = form.save()
  return HttpResponseRedirect(reverse('sales_lead_view', args=[lead.id]))
 return render_to_response('sales/lead_edit', {'form': form, 'lead': lead}, context_instance=RequestContext(request), response_format=response_format)

@ treeio_login_required @ handle_response_format def lead_edit ( request , lead_id , response_format = 'html' ) : lead = get_object_or_404 ( Lead , pk = lead_id ) if ( ( not request . user . profile . has_permission ( lead , mode = 'w' ) ) and ( not request . user . profile . is_admin ( 'treeio.sales' ) ) ) : return user_denied ( request , "You don't have access to this Lead" , response_format ) if request . POST : form = LeadForm ( request . user . profile , request . POST , instance = lead ) else : form = LeadForm ( request . user . profile , instance = lead ) if form . is_valid ( ) : lead = form . save ( ) return HttpResponseRedirect ( reverse ( 'sales_lead_view' , args = [ lead . id ] ) ) return render_to_response ( 'sales/lead_edit' , { 'form' : form , 'lead' : lead } , context_instance = RequestContext ( request ) , response_format = response_format )
lead edit .