@treeio_login_required
@handle_response_format
def source_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")
 if request.POST:
  if ('cancel' not in request.POST):
   source = SaleSource()
   form = SaleSourceForm(request.user.profile, request.POST, instance=source)
   if form.is_valid():
    source = form.save()
    source.set_user_from_request(request)
    return HttpResponseRedirect(reverse('sales_source_view', args=[source.id]))
  else:
   return HttpResponseRedirect(reverse('sales_settings_view'))
 else:
  form = SaleSourceForm(request.user.profile)
 all_products = Object.filter_by_request(request, Product.objects.filter(parent__isnull=True))
 all_sources = Object.filter_by_request(request, SaleSource.objects)
 return render_to_response('sales/source_add', {'form': form, 'sources': all_sources, 'products': all_products}, context_instance=RequestContext(request), response_format=response_format)

@ treeio_login_required @ handle_response_format def source_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" ) if request . POST : if ( 'cancel' not in request . POST ) : source = SaleSource ( ) form = SaleSourceForm ( request . user . profile , request . POST , instance = source ) if form . is_valid ( ) : source = form . save ( ) source . set_user_from_request ( request ) return HttpResponseRedirect ( reverse ( 'sales_source_view' , args = [ source . id ] ) ) else : return HttpResponseRedirect ( reverse ( 'sales_settings_view' ) ) else : form = SaleSourceForm ( request . user . profile ) all_products = Object . filter_by_request ( request , Product . objects . filter ( parent__isnull = True ) ) all_sources = Object . filter_by_request ( request , SaleSource . objects ) return render_to_response ( 'sales/source_add' , { 'form' : form , 'sources' : all_sources , 'products' : all_products } , context_instance = RequestContext ( request ) , response_format = response_format )
ticketstatus add .