@treeio_login_required
@handle_response_format
def opportunity_add(request, lead_id=None, response_format='html'):
 lead = None
 if lead_id:
  lead = get_object_or_404(Lead, pk=lead_id)
 if request.POST:
  if ('cancel' not in request.POST):
   form = OpportunityForm(request.user.profile, lead, request.POST)
   if form.is_valid():
    opportunity = form.save(commit=False)
    convert(opportunity, 'amount')
    opportunity.set_user_from_request(request)
    return HttpResponseRedirect(reverse('sales_opportunity_view', args=[opportunity.id]))
  else:
   return HttpResponseRedirect(reverse('sales_opportunity_index'))
 else:
  form = OpportunityForm(request.user.profile, lead)
 return render_to_response('sales/opportunity_add', {'form': form}, context_instance=RequestContext(request), response_format=response_format)

@ treeio_login_required @ handle_response_format def opportunity_add ( request , lead_id = None , response_format = 'html' ) : lead = None if lead_id : lead = get_object_or_404 ( Lead , pk = lead_id ) if request . POST : if ( 'cancel' not in request . POST ) : form = OpportunityForm ( request . user . profile , lead , request . POST ) if form . is_valid ( ) : opportunity = form . save ( commit = False ) convert ( opportunity , 'amount' ) opportunity . set_user_from_request ( request ) return HttpResponseRedirect ( reverse ( 'sales_opportunity_view' , args = [ opportunity . id ] ) ) else : return HttpResponseRedirect ( reverse ( 'sales_opportunity_index' ) ) else : form = OpportunityForm ( request . user . profile , lead ) return render_to_response ( 'sales/opportunity_add' , { 'form' : form } , context_instance = RequestContext ( request ) , response_format = response_format )
opportunity add .