@treeio_login_required
@handle_response_format
def lead_add(request, lead_id=None, response_format='html'):
 all_leads = Object.filter_by_request(request, Lead.objects)
 if request.POST:
  if ('cancel' not in request.POST):
   lead = Lead()
   form = LeadForm(request.user.profile, request.POST, instance=lead)
   if form.is_valid():
    lead = form.save()
    lead.set_user_from_request(request)
    return HttpResponseRedirect(reverse('sales_lead_view', args=[lead.id]))
  else:
   return HttpResponseRedirect(reverse('sales_lead_index'))
 else:
  form = LeadForm(request.user.profile)
 return render_to_response('sales/lead_add', {'form': form, 'leads': all_leads}, context_instance=RequestContext(request), response_format=response_format)

@ treeio_login_required @ handle_response_format def lead_add ( request , lead_id = None , response_format = 'html' ) : all_leads = Object . filter_by_request ( request , Lead . objects ) if request . POST : if ( 'cancel' not in request . POST ) : lead = Lead ( ) form = LeadForm ( request . user . profile , request . POST , instance = lead ) if form . is_valid ( ) : lead = form . save ( ) lead . set_user_from_request ( request ) return HttpResponseRedirect ( reverse ( 'sales_lead_view' , args = [ lead . id ] ) ) else : return HttpResponseRedirect ( reverse ( 'sales_lead_index' ) ) else : form = LeadForm ( request . user . profile ) return render_to_response ( 'sales/lead_add' , { 'form' : form , 'leads' : all_leads } , context_instance = RequestContext ( request ) , response_format = response_format )
lead add .