home ohne Pfand

This commit is contained in:
TKroenert 2011-03-05 04:25:46 +01:00
parent 47267b8213
commit dddb18cd87
1 changed files with 6 additions and 3 deletions

View File

@ -7,9 +7,12 @@ from buyable.models import Purchase, Buyable
@login_required
def startpage(request):
allMost = Purchase.objects.values('buyable__name').annotate(num_buys=Count('buyable')).order_by('-num_buys')
usersMost = Purchase.objects.values('buyable__name').filter(order__user=request.user.id).annotate(num_buys=Count('buyable')).order_by('-num_buys')
usersLast = Purchase.objects.values('buyable__name').filter(order__user=request.user.id).order_by('-order__dateTime')
''' Diese Funktion wird wahrscheinlich viel Last erzeugen, da
sie ueber mehrere Tabellen joined,filtered und wieder reduced.
'''
allMost = Purchase.objects.filter(isDeposit=False).values('buyable__name').annotate(num_buys=Count('buyable')).order_by('-num_buys')
usersMost = Purchase.objects.filter(isDeposit=False).values('buyable__name').filter(order__user=request.user.id).annotate(num_buys=Count('buyable')).order_by('-num_buys')
usersLast = Purchase.objects.filter(isDeposit=False).values('buyable__name').filter(order__user=request.user.id).order_by('-order__dateTime')
return render_to_response("main/startpage.html", {'allMost' : allMost,'usersMost': usersMost, 'usersLast' : usersLast}, RequestContext(request))
def register(request):