noch mehr stats fuer die HOME seite..

This commit is contained in:
TKroenert 2011-03-05 04:09:04 +01:00
parent 50429f4f78
commit 47267b8213
2 changed files with 27 additions and 3 deletions

View File

@ -1,8 +1,19 @@
{% extends "base.html" %}
{% block "content" %}
{% if allMost %}
Am beliebtesten ist: <br /> <br />
{% for buyable in allMost %}
{{ buyable.buyable__name }} ( {{ buyable.num_buys }} mal) <br />
{% endfor %}
<br />
{% else %}
{{ error }}
Noch niemand hat was gekauft?
{% endif %}
<hr>
{% if usersMost %}
Am oeftesten hatten alle: <br /> <br />
Am oeftesten hattest du: <br /> <br />
{% for buyable in usersMost %}
{{ buyable.buyable__name }} ( {{ buyable.num_buys }} mal) <br />
{% endfor %}
@ -11,4 +22,15 @@
{{ error }}
Nix gekauft?
{% endif %}
<hr>
{% if usersLast %}
Als letztes hattest du: <br /> <br />
{% for buyable in usersLast %}
{{ buyable.buyable__name }} <br />
{% endfor %}
<br />
{% else %}
{{ error }}
Noch nix gekauft?
{% endif %}
{% endblock %}

View File

@ -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))