@treeio_login_required
@handle_response_format
def source_view(request, source_id, response_format='html'):
 source = get_object_or_404(SaleSource, pk=source_id)
 if ((not request.user.profile.has_permission(source)) and (not request.user.profile.is_admin('treeio.sales'))):
  return user_denied(request, message="You don't have access to this Sale Status")
 query = Q(source=source)
 if request.GET:
  query = (query & _get_filter_query(request.GET))
 orders = Object.filter_by_request(request, SaleOrder.objects.filter(query))
 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_view', {'source': source, 'sources': all_sources, 'products': all_products, 'orders': orders}, context_instance=RequestContext(request), response_format=response_format)

@ treeio_login_required @ handle_response_format def source_view ( request , source_id , response_format = 'html' ) : source = get_object_or_404 ( SaleSource , pk = source_id ) if ( ( not request . user . profile . has_permission ( source ) ) and ( not request . user . profile . is_admin ( 'treeio.sales' ) ) ) : return user_denied ( request , message = "You don't have access to this Sale Status" ) query = Q ( source = source ) if request . GET : query = ( query & _get_filter_query ( request . GET ) ) orders = Object . filter_by_request ( request , SaleOrder . objects . filter ( query ) ) 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_view' , { 'source' : source , 'sources' : all_sources , 'products' : all_products , 'orders' : orders } , context_instance = RequestContext ( request ) , response_format = response_format )
orders filtered by source .