@treeio_login_required
@handle_response_format
def status_add(request, response_format='html'):
 if (not request.user.profile.is_admin('treeio.sales')):
  return user_denied(request, message="You don't have administrator access to the Sales module")
 status = None
 if request.POST:
  if ('cancel' not in request.POST):
   status = SaleStatus()
   form = SaleStatusForm(request.user.profile, request.POST, instance=status)
   if form.is_valid():
    status = form.save()
    status.set_user_from_request(request)
    return HttpResponseRedirect(reverse('sales_status_view', args=[status.id]))
  else:
   return HttpResponseRedirect(reverse('sales_settings_view'))
 else:
  form = SaleStatusForm(request.user.profile)
 all_products = Object.filter_by_request(request, Product.objects.filter(parent__isnull=True))
 return render_to_response('sales/status_add', {'form': form, 'status': status, 'products': all_products}, context_instance=RequestContext(request), response_format=response_format)

@ treeio_login_required @ handle_response_format def status_add ( request , response_format = 'html' ) : if ( not request . user . profile . is_admin ( 'treeio.sales' ) ) : return user_denied ( request , message = "You don't have administrator access to the Sales module" ) status = None if request . POST : if ( 'cancel' not in request . POST ) : status = SaleStatus ( ) form = SaleStatusForm ( request . user . profile , request . POST , instance = status ) if form . is_valid ( ) : status = form . save ( ) status . set_user_from_request ( request ) return HttpResponseRedirect ( reverse ( 'sales_status_view' , args = [ status . id ] ) ) else : return HttpResponseRedirect ( reverse ( 'sales_settings_view' ) ) else : form = SaleStatusForm ( request . user . profile ) all_products = Object . filter_by_request ( request , Product . objects . filter ( parent__isnull = True ) ) return render_to_response ( 'sales/status_add' , { 'form' : form , 'status' : status , 'products' : all_products } , context_instance = RequestContext ( request ) , response_format = response_format )
status add .