From 47267b8213f090beea94d1f747bd27aa3f93b235 Mon Sep 17 00:00:00 2001 From: TKroenert Date: Sat, 5 Mar 2011 04:09:04 +0100 Subject: [PATCH] noch mehr stats fuer die HOME seite.. --- k4ever/main/templates/main/startpage.html | 24 ++++++++++++++++++++++- k4ever/main/views.py | 6 ++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/k4ever/main/templates/main/startpage.html b/k4ever/main/templates/main/startpage.html index 54335c6..33d9986 100644 --- a/k4ever/main/templates/main/startpage.html +++ b/k4ever/main/templates/main/startpage.html @@ -1,8 +1,19 @@ {% extends "base.html" %} {% block "content" %} + {% if allMost %} + Am beliebtesten ist:

+ {% for buyable in allMost %} + {{ buyable.buyable__name }} ( {{ buyable.num_buys }} mal)
+ {% endfor %} +
+ {% else %} + {{ error }} + Noch niemand hat was gekauft? + {% endif %} +
{% if usersMost %} - Am oeftesten hatten alle:

+ Am oeftesten hattest du:

{% for buyable in usersMost %} {{ buyable.buyable__name }} ( {{ buyable.num_buys }} mal)
{% endfor %} @@ -11,4 +22,15 @@ {{ error }} Nix gekauft? {% endif %} +
+ {% if usersLast %} + Als letztes hattest du:

+ {% for buyable in usersLast %} + {{ buyable.buyable__name }}
+ {% endfor %} +
+ {% else %} + {{ error }} + Noch nix gekauft? + {% endif %} {% endblock %} diff --git a/k4ever/main/views.py b/k4ever/main/views.py index 3c1d44b..865482b 100644 --- a/k4ever/main/views.py +++ b/k4ever/main/views.py @@ -7,8 +7,10 @@ from buyable.models import Purchase, Buyable @login_required def startpage(request): - usersMost = Purchase.objects.values('buyable__name').annotate(num_buys=Count('buyable')).order_by('-num_buys') - return render_to_response("main/startpage.html", {'usersMost': usersMost}, RequestContext(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') + return render_to_response("main/startpage.html", {'allMost' : allMost,'usersMost': usersMost, 'usersLast' : usersLast}, RequestContext(request)) def register(request): return render_to_response("registration/register.html", RequestContext(request))