From 22a94820738824527277e21f2f37bc77638e12bc Mon Sep 17 00:00:00 2001 From: Jess Date: Wed, 27 Aug 2014 10:02:10 +0200 Subject: [PATCH] use template extensions make rating work --- db.sqlite3 | Bin 82944 -> 83968 bytes meta/static/js/main.js | 6 +- meta/templates/base.html | 69 +++++++++++++ meta/templates/index.html | 201 ++++++++++++++------------------------ meta/templates/rate.html | 7 ++ meta/views.py | 26 +++-- meta/views.pyc | Bin 1411 -> 1996 bytes mlpccg-web/urls.py | 9 +- mlpccg-web/urls.pyc | Bin 468 -> 520 bytes mlpccg/CardDb.py | 2 +- mlpccg/DeckList.py | 2 +- 11 files changed, 174 insertions(+), 148 deletions(-) create mode 100644 meta/templates/base.html create mode 100644 meta/templates/rate.html diff --git a/db.sqlite3 b/db.sqlite3 index 6cbee9fb87b2c8046c77d193c01fb0ca08989d12..d6eb13b53e58baff15226414eec3830a7311d744 100644 GIT binary patch delta 1836 zcmZ{kO>7%Q6vtgVxtZDGcv+q*%JY+X z`RLnALV7Y+Eab=KVs0j{499q-j1<48lGUHWij5sxbtG&!xI8Zp$S*96zcW>+l;2z^ z73AmgrI}n&9?2J`W{bILJIYJ-H7R9SieuT9qZ3iu(DcIme7;nkTn2uj9C*(%;8^ItH-;k{L;nu2Xr*L9-8(kmq< zV{a92tL$dwn$^0SL`)3arQaX7S>2(#ZX6hkMcWLAg@)0m&U zdmv3wJQ3ujTK|WFlv0(HZJ3rVlA|3Q9DOms_O`s%WG}(y5WOiJ#x_6y15NwM-FI)0 z-c!$rUu5^k(K&>!dq`UU-rE~ATR3w@8iMie|;t-32)P@7~?bqA7!Us@>e4Ajzi@iH2piIpb5PHdN_g;DbbCdvA zJ#n=QUah)kpX^BlK>9I`rzxFXHud&nzrKZrz@{hu_MZ4RxCSnR&8nN$CATdEBq&G; za4O;^LjaOkNB}?Lw(-EUZ+X{LaZuw#t{5TA+!z=J7xK(p|pe!Om z0H?q@^FBDi{7K+3zYdOX{CN;YL+B{H<%@^lM`0l@gy0=`tL8orJ3|PP&gMmLl} z_$`dZQ3MFE8^CVi(VE){JKeJTU=Zjl=_bEi51;PwX9KXUvO7PMpK4&acTDqN3{(yo zmw;lbbv6Vx*i(%%AW4U_An#Dp7H^@cd~S;(ru^AJm;`(q#*Kt#agr&5%PqM3=n3}i z{-OQD4@1>k{xan6yC23vV@1l-%YK#|rCLaLm1A!3wRv~PU|l)wv7)A`tOdG8e*mXj)ZzdD delta 215 zcmZpez}nEkIzgKC1_J{_;6w#`#v2*>&;@F@3NSk7`Z01e`%X+#8SJN>+3H) z<^aZ@)7e!R7XtMJGH(B=%E-;e?9U`Jon41 + + + + + + + + meta is magic + + + + + + + + + + + + + + + {% block jumbotron %}{% endblock %} + +
+ {% block content %}{% endblock %} +
+ +
+

© Yukkuri Games, 2014

+
+
+ + + + + + diff --git a/meta/templates/index.html b/meta/templates/index.html index f165607..e4f9e6f 100644 --- a/meta/templates/index.html +++ b/meta/templates/index.html @@ -1,135 +1,76 @@ - - - - - - - - - meta is magic - - +{% extends "base.html" %} - - - - - - - - - - + +{% endblock %} diff --git a/meta/templates/rate.html b/meta/templates/rate.html new file mode 100644 index 0000000..c9627a5 --- /dev/null +++ b/meta/templates/rate.html @@ -0,0 +1,7 @@ +{% extends "base.html" %} + +{% block content %} + +{{ label }} + +{% endblock %} diff --git a/meta/views.py b/meta/views.py index fc1a7af..bb97599 100644 --- a/meta/views.py +++ b/meta/views.py @@ -1,5 +1,6 @@ from django.shortcuts import render -from meta.models import TournamentModel +from django.template import RequestContext +from meta.models import TournamentModel, RecordModel from mlpccg.CardDb import CARDDB from mlpccg.DeckList import DeckList from mlpccg.Clustering import Clustering @@ -7,21 +8,26 @@ from mlpccg.Clustering import Clustering def index(request): tournament_models = TournamentModel.objects.all().order_by('-date') tournament_data = [] - placements = [] for tournament in tournament_models: tournament_records = tournament.recordmodel_set.all().order_by('placement') - tournament_decks = [] - for record in tournament_records: - decklist = DeckList(name=record.decklist.name, url=record.decklist.url) - tournament_decks += [decklist] - if len(decklist.cards) > 0: - placements += [{'decklist': decklist, 'placement': record.placement}] - + tournament_decks = [DeckList(name=record.decklist.name, url=record.decklist.url) for record in tournament_records] tournament_data += [{'tournament': tournament, 'decklists': tournament_decks}] + records = RecordModel.objects.all() + placements = [{'decklist': DeckList(name=record.decklist.name, url=record.decklist.url), 'placement': record.placement} for record in records if record.decklist.url] clustering = Clustering(records=placements) ranking = [(int(avg), label, [decklist for decklist in clustering.clusters[label]]) for avg, label in clustering.ranking()] return render(request, 'index.html', { 'ranking': ranking, - 'tournaments': tournament_data}) + 'tournaments': tournament_data}, + context_instance=RequestContext(request)) + +def rate(request): + records = RecordModel.objects.all() + placements = [{'decklist': DeckList(name=record.decklist.name, url=record.decklist.url), 'placement': record.placement} for record in records if record.decklist.url] + clustering = Clustering(records=placements) + decklist = DeckList(url=request.POST['url']) + label = clustering.predict(decklist) + + return render(request, 'rate.html', {}) diff --git a/meta/views.pyc b/meta/views.pyc index 0c37ebc34749879d4c47f8eb7df7e5a5eb67c02d..cde0787ef6173065228635a107d936a368cb6be5 100644 GIT binary patch literal 1996 zcmbtV&u{BQ5T3OY=XYCrC_H{6fykxF1qCD!f|r~S6mXw}6wy~)dr6&VJFR!~=tK6Y z{3#sYf5#OGzL`y$aNz(^Jl@%zotd5azP10ypgaHR&-0izKM(IO@R$lB!Cz5Elq;Gm zQmlKFd6fG!_nq!j)}Xve^Csm1%>y^vpsYoCo91n&H!15--lcih=>cUu%KJ3$LvPV< zMDqb9Z5bR;(xLNV7YU?);Wtzm*#M%{MWRcmA3zWF?OGcWcBKElmvx`sZM~~_*)jhHUs=9p4 zs<$;d;PIo`MW5|+yacget#<}YeMdj)cv6?M$}D)TtunF^96uN zltouMbEoBmhj^SYrx=Z|SGgW9wJ~WN*T+>dfn_mg=gQtHkwT>nR@dJH$S{9jk@UAQG_YG2=n$ z@?=XS0NqW3k$VPUE=bKNc9a$(o$#H2Zh^tzF%zjFWW+vPB^`F~h-a~kTcgXo<@+LF z@-aUGNd-qI@^vrB zOO{cwSdGl}sz@XJa2VpM5W#n)#{1jT@%EI?fKsB01Wiq=8IR){w zncjXSgqp&mt^LEt!twGwYz*Ir*i}GA{{hV0lh2UrI@6ysQVrANNFAXJERVd-@!#SK BkdOcX literal 1411 zcmbVMOK;Oa5dPLq;yh_VLV^%{%1eL^5f9+E!}!dM?{x^0#bpIfMDH$ za*(;JL>~6Lb*d2G(5EX%GBr9f zIg4ag>KmkgoG-Fjkjk0)Fps3Vb=-aD4~ILY&UuD1JbfQ)Q(Bs2*;NZ|WERh+A*b)q z?Xj6|eMA-mBm#+pYZ6?Z^ID(~m;!}kPZyUzkqZpRKTuSVSCG)P4j_R7s@AoJ%M5vy zToV)?Ocjxf+(S}B;vu5oQm#`qr>G;ZA+KX9@Up1EG+0TRoG+^4w1Vsaxr^9gJ7G59 z=oUjiuputa5BNIF9qUwKJO`9BsxLhpoWH=KX(OWCE)^9;gB#5oNIE?6aQq6N9289y zEtq@AZS}mha@qjNkB8$nxZ668DC3s+>{{UlMH^-lIjuv}c0h$%)PaMjjls1`w`pWJE+NBGNF2W=+41U;U;HGnvV7o<&-- zV@zvv**h_*Dt`)Qr$oGI-N~W5_euBdvT=g>B$1)fwue9|Tb?q??09lzc>BrTsdt8(u!Uv72J~b^ZdA C6)(X6 diff --git a/mlpccg-web/urls.py b/mlpccg-web/urls.py index 7cf9e46..4870720 100644 --- a/mlpccg-web/urls.py +++ b/mlpccg-web/urls.py @@ -3,10 +3,9 @@ from django.conf.urls import patterns, include, url from django.contrib import admin admin.autodiscover() -urlpatterns = patterns('', - # Examples: - # url(r'^blog/', include('blog.urls')), - - url(r'^meta/$', 'meta.views.index'), +urlpatterns = patterns( + '', url(r'^admin/', include(admin.site.urls)), + url(r'^meta/$', 'meta.views.index'), + url(r'^meta/rate$', 'meta.views.rate'), ) diff --git a/mlpccg-web/urls.pyc b/mlpccg-web/urls.pyc index 4140450d63f8550456f6736fd4d63509205b46b8..ae1775fb50f1e9d0bcf90574fc45bb7172000d2f 100644 GIT binary patch delta 161 zcmcb@+`%Hv{F#@l!ShdWG6NK_18D~!E-srW?P`|F#E{C$kj2iB#lg_b$j}VrGBc#G zGNiD<*z61`Kq)4MW)_AhPKFdthF}e@iCrFSi7C06dHNI2C@FITO^eG-ElJcbN-RlL oDdq?AL0rAE%+&H?J&@qUpJ#>mfWk6N0*qWt%#6&85{x{I0B><33;+NC delta 115 zcmeBRxxy^X{F#?4V*8KaWCkc;2ht8eT%0vg+Epusm7$r5A(fdSg^eK<$Y5p2VrR(W zU}$Cpi8nJdL~$~turmZ}a7>)$G4YiQH%NP2VoGjip8jM_#