@treeio_login_required
@handle_response_format
def opportunity_delete(request, opportunity_id, response_format='html'):
 opportunity = get_object_or_404(Opportunity, pk=opportunity_id)
 if ((not request.user.profile.has_permission(opportunity, mode='w')) and (not request.user.profile.is_admin('treeio.sales'))):
  return user_denied(request, "You don't have access to this Sale Status", response_format)
 if request.POST:
  if ('delete' in request.POST):
   if ('trash' in request.POST):
    opportunity.trash = True
    opportunity.save()
   else:
    opportunity.delete()
   return HttpResponseRedirect(reverse('sales_opportunity_index'))
  elif ('cancel' in request.POST):
   return HttpResponseRedirect(reverse('sales_opportunity_view', args=[opportunity.id]))
 all_opportunities = Object.filter_by_request(request, Opportunity.objects)
 return render_to_response('sales/opportunity_delete', {'opportunity': opportunity, 'opportunities': all_opportunities}, context_instance=RequestContext(request), response_format=response_format)

@ treeio_login_required @ handle_response_format def opportunity_delete ( request , opportunity_id , response_format = 'html' ) : opportunity = get_object_or_404 ( Opportunity , pk = opportunity_id ) if ( ( not request . user . profile . has_permission ( opportunity , mode = 'w' ) ) and ( not request . user . profile . is_admin ( 'treeio.sales' ) ) ) : return user_denied ( request , "You don't have access to this Sale Status" , response_format ) if request . POST : if ( 'delete' in request . POST ) : if ( 'trash' in request . POST ) : opportunity . trash = True opportunity . save ( ) else : opportunity . delete ( ) return HttpResponseRedirect ( reverse ( 'sales_opportunity_index' ) ) elif ( 'cancel' in request . POST ) : return HttpResponseRedirect ( reverse ( 'sales_opportunity_view' , args = [ opportunity . id ] ) ) all_opportunities = Object . filter_by_request ( request , Opportunity . objects ) return render_to_response ( 'sales/opportunity_delete' , { 'opportunity' : opportunity , 'opportunities' : all_opportunities } , context_instance = RequestContext ( request ) , response_format = response_format )
opportunity delete .