From 50429f4f78b2ba02bf2a9053424fe6fc672e1ca0 Mon Sep 17 00:00:00 2001 From: TKroenert Date: Sat, 5 Mar 2011 03:45:03 +0100 Subject: [PATCH 1/5] neues usersettings, weiteres item --- k4ever/k4ever.db | Bin 64512 -> 66560 bytes k4ever/media/img/buyable/eis.jpeg | Bin 0 -> 7452 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100755 k4ever/media/img/buyable/eis.jpeg diff --git a/k4ever/k4ever.db b/k4ever/k4ever.db index a822f241d43297a050a4f6df741a47acd9259062..1129fea81e363dc75f2401656e91d186a8ecbe21 100644 GIT binary patch delta 1895 zcmah~U1$_n6uxK9>~6B|u33U*lg-9mh$R->+_^Ke^V6bP)P!o1))bQ%T4DAtf4fOY zqSYdeN})ojXeUp73Mf`+Ug|*UQy;2rp)a-|wvs~7mXcQ62DCKjOYh8@`ri)Anb~u{ z?|kRpd+xbMSMlfx@l@QGC4^*8C%5sBEjJoJDa^|u5v~)Q5|#uDt~*ijJD7c243R`Q z9G(V%Y}P7{B$Z56F=aii8!9uDCq|f(RwctwLAR~UYf(<1CS|6ir8TB0n&Nz! zsRP$7nT)z_Nue~8v47E;Ln2-wcm;3a-{?-_5{5&VfVI>`=lYAyu?;mrK6@W_5?sX7 z_$hW`8Ot0UK@k_pCOayo?9TqVO)c0BGRsJ%oT{^ul4BXh@;qTFV`wx}%4p1>wHF3N zu|~j~1aIR_9%KnqegR4S&XMVLfF#jboSC|Kc6=<%H3eKDxQZ(r_A@s51(5&S={43e_GWU^Y@EWFJ>hbW@(?)vOyblOXc1M6z}F#Q4m_ z^o%uLFq1S*H$z+a8KOLf#L|jEC7nJb3fn_f!p_G<88cNWZ7`-u64bJn@0U%om8NAi zxpQxC8y8HzTH@N9;e~b8DD_W?BCBadll2UR8pewpob&I$Zt~*1L+~!%;d`-+F(0~h z>)N%lerVKR9d+(r4vMz;Ln?j(kK++Mhy~n_=WrfB#5ul!lQ@b4JX{Q$U4q!;g^PQ( z(Y4s%*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za%%lqhu=V1^~5edpe%c~Zh~UMazXNaZB#_s_D5y9ksWMd17Go3 uMNLsUM89jE@q;HBPip-Lu_t7TJb&b_^6c(g%{cs-5JO1a=>&!Le*6VwWw~bn diff --git a/k4ever/media/img/buyable/eis.jpeg b/k4ever/media/img/buyable/eis.jpeg new file mode 100755 index 0000000000000000000000000000000000000000..e68b18c855b00b485b6ebe218403ad4d94eb397d GIT binary patch literal 7452 zcmb7}c{J2t{Qut!Mp?&h8vB+lSwnWh*w+zJWFL_cS+kZhA7&U!k$s!77TLEb+mIy& z*-A!)D3e|I`kvo8zjJ)d<(<$MWXH8F%60#sB~fbqou z&gTJrfEGkULj$6{m}qHf>A;Ni;0v)ZFkE7Uu&}W~SRfE~E*LjE2b2>6;Su72^6?1> z2(WVtiwg6L!uSRF{})1aaTH7kW~QfS=I4NL@c)17yc>Yf1C2l|h)NishERbZROh__ z3;?KT|2NzJD>?u~Lkp&+qQ7vpSpjM)5DgUwL`@B*qouvrOnu=(06I1yc`&=Ku(caU zoC1ndL{Tq3t%%F!e%QS;-DItm|A*6zn4TK00PqAsKlNcFftz;6q03G`K9iZBw4D7xn&*Y* zx8={d;*~S4s(1gO2g6NyX%ay%r&pBG79)TENOg{ zWxATjdxaZ(7Fo<@ zaGo{7xx!Z(p;mf%fi-mPklO(8#s_Nnt6=v8*n(GpM8>2}7&!gfQ3rMxv1qLr_o zFoVIwf&P|Hs6?+ZC)uiXX*z{UimQp$-}+)~>ojD8ZaJd;`L0W5a_uj>KfL`70=88v z6_%c`TLR&N2h|4wb36+o@snGXuz(G&79(lFL}*H@WaO%1?Snnq;w4n(riJptrI$(S;U>o;<@4Be=tJ#! z3GAwpcY}|AGt6&x8XXVR@%M&7p1UiTU^7hY0=5 zhy~gImX80Ddzlv>OP9?AlFT`J<%BTWi&REVyj7(g*3Kfur7fd>Z=!C`tWhi)tOGGj zBeus8gf+bPGOkd=8K5(aKDIvzvvYoLm+hdL2&O^4%C9c(*oNpsjFab%;v>1=R5|+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zu&>-4yyH11a@XWSA>c!D-})=+5QYC3KY}0%Da7ZmSox zv3t5aJPQ(4ge7V;D(>zzybS-{$SqOpC@c-L?JX<*!z0ZcpD!27;cEO*;)gF%el@5g zyI_2Pw8e`r!d*tI<+LHQ*L}|ca}#d^`2hiSuUk@;YJjh;X7b;d??XF}$%e@4mkc+J z1@Ui6D@#*#N@*~qSEDtO)P}f-5;DImf*Tr)6ytj0j-n#l4FkB2q<$-LyN9>ij2U?C zPvdSc8)7_@l^$r;8-Fs<9dt|omK<)$DW=?(HE(JmSX8v+78kY@DENkCB$P~*YN*3I znw1s1`lxSUxhI)z>Jt{{ytcAgBP%NsX^tAqub7bNl$CwFzZdIW&^lqGt14k?YTeoC pVHtkon`Q5SfWNFP&*M~&79F=eAVfuE$u(H1p^ Date: Sat, 5 Mar 2011 04:09:04 +0100 Subject: [PATCH 2/5] 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)) From dddb18cd875d7aeb3f959b7527701001ccdcb8b9 Mon Sep 17 00:00:00 2001 From: TKroenert Date: Sat, 5 Mar 2011 04:25:46 +0100 Subject: [PATCH 3/5] home ohne Pfand --- k4ever/main/views.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/k4ever/main/views.py b/k4ever/main/views.py index 865482b..8addc4d 100644 --- a/k4ever/main/views.py +++ b/k4ever/main/views.py @@ -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): From 886dc7eb4519aa33cfdbb8c1c58c1db9fe64a1f8 Mon Sep 17 00:00:00 2001 From: TKroenert Date: Sat, 5 Mar 2011 04:55:16 +0100 Subject: [PATCH 4/5] API fuer den store --- k4ever/api/__init__.py | 0 k4ever/api/models.py | 3 ++ k4ever/api/tests.py | 23 ++++++++++++++ k4ever/api/urls.py | 9 ++++++ k4ever/api/views.py | 72 ++++++++++++++++++++++++++++++++++++++++++ k4ever/urls.py | 1 + 6 files changed, 108 insertions(+) create mode 100644 k4ever/api/__init__.py create mode 100644 k4ever/api/models.py create mode 100644 k4ever/api/tests.py create mode 100644 k4ever/api/urls.py create mode 100644 k4ever/api/views.py diff --git a/k4ever/api/__init__.py b/k4ever/api/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/k4ever/api/models.py b/k4ever/api/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/k4ever/api/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/k4ever/api/tests.py b/k4ever/api/tests.py new file mode 100644 index 0000000..2247054 --- /dev/null +++ b/k4ever/api/tests.py @@ -0,0 +1,23 @@ +""" +This file demonstrates two different styles of tests (one doctest and one +unittest). These will both pass when you run "manage.py test". + +Replace these with more appropriate tests for your application. +""" + +from django.test import TestCase + +class SimpleTest(TestCase): + def test_basic_addition(self): + """ + Tests that 1 + 1 always equals 2. + """ + self.failUnlessEqual(1 + 1, 2) + +__test__ = {"doctest": """ +Another way to test that 1 + 1 is equal to 2. + +>>> 1 + 1 == 2 +True +"""} + diff --git a/k4ever/api/urls.py b/k4ever/api/urls.py new file mode 100644 index 0000000..5434be8 --- /dev/null +++ b/k4ever/api/urls.py @@ -0,0 +1,9 @@ +from django.conf.urls.defaults import * + +#/api/ +urlpatterns = patterns('', + (r'^store/$', 'api.views.showItems'), + (r'^store/show/(\d+)/$', 'api.views.showItem'), + (r'^store/buy/(\d+)/(|with/deposit|only/deposit)/?$', 'api.views.buyItem'), + (r'^store/history/?$', 'api.views.history'), +) diff --git a/k4ever/api/views.py b/k4ever/api/views.py new file mode 100644 index 0000000..364c227 --- /dev/null +++ b/k4ever/api/views.py @@ -0,0 +1,72 @@ +# -*- coding: utf-8 -*- +from django.contrib.auth.decorators import login_required +from django.http import HttpResponse + +import datetime +from buyable.models import Buyable, Purchase, Order +from django.core import serializers + + +@login_required +def showItems(request): + # FIXME: Implement pagination here + items = Buyable.objects.all() + + #return json-container + container = serializers.serialize('json', items) + return HttpResponse(container,'application/javascript') + +@login_required +def showItem(request, itemid): + try: + item = Buyable.objects.get(id=itemid) + except Buyable.DoesNotExist: + # baww, kein item mit der id :( (oder mutax trollt rum) + return HttpResponse(status=400) + + #return json-container + container = serializers.serialize('json', item) + return HttpResponse(container,'application/javascript') + + +@login_required +def buyItem(request, itemid, buymode=""): + user = request.user + try: + item = Buyable.objects.get(id=itemid) + except Buyable.DoesNotExist: + # oh no! kein item mit der id :( mutax trollt rum) + return HttpResponseRedirect("/store/buy/") + """ tristate variable buymode: + "" only item + "with/deposit" item and deposit + "only/deposit" only deposit + """ + order = Order() + order.create(user) + order.save() # for the id! + if buymode == "" or buymode == "with/deposit": + p = Purchase.create(order, item, isDeposit=False) + p.order = order + p.save() + # TANNEK! if buymode == "with/dopsit" or buymode == "only/deposit": + if buymode == "with/deposit" or buymode == "only/deposit": + p = Purchase.create(order, item, isDeposit=True) + p.order = order + p.save() + order.updatePrice(commit=True) + order.save() + + #return json-container + #container = serializers.serialize('json', items) + #return HttpResponse(container,'application/javascript') + return HttpResponse(status=200) + #return HttpResponseRedirect("/store/bought/%s/" % (order.id)) + +@login_required +def history(request): + hist = Order.objects.filter(user=request.user.id).order_by("-dateTime") + #return json-container + container = serializers.serialize('json', hist) + return HttpResponse(container,'application/javascript') + diff --git a/k4ever/urls.py b/k4ever/urls.py index a5469ca..ab668b5 100644 --- a/k4ever/urls.py +++ b/k4ever/urls.py @@ -13,6 +13,7 @@ urlpatterns = patterns('', # (r'^admin/doc/', include('django.contrib.admindocs.urls')), # user stuff? go to main (r'^$', 'main.views.startpage'), + (r'^api/', include('api.urls')), (r'^user/', include('main.urls')), (r'^transaction/', include('transaction.urls')), (r'^store/', include('buyable.urls')), From c2b2bf5655f3ab188509a7c3f2c8ae5aceb95641 Mon Sep 17 00:00:00 2001 From: TKroenert Date: Sat, 5 Mar 2011 05:01:03 +0100 Subject: [PATCH 5/5] *fix: json will umbedingt eine liste,damit es die serialized --- k4ever/api/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/k4ever/api/views.py b/k4ever/api/views.py index 364c227..1873c83 100644 --- a/k4ever/api/views.py +++ b/k4ever/api/views.py @@ -25,7 +25,7 @@ def showItem(request, itemid): return HttpResponse(status=400) #return json-container - container = serializers.serialize('json', item) + container = serializers.serialize('json', [item]) return HttpResponse(container,'application/javascript') @@ -67,6 +67,6 @@ def buyItem(request, itemid, buymode=""): def history(request): hist = Order.objects.filter(user=request.user.id).order_by("-dateTime") #return json-container - container = serializers.serialize('json', hist) + container = serializers.serialize('json', [hist]) return HttpResponse(container,'application/javascript')