From 683f926ed63413beb134d235b0c10d3727af3cbf Mon Sep 17 00:00:00 2001 From: koksnuss Date: Wed, 29 Apr 2020 00:19:42 +0200 Subject: [PATCH] add feature / now works :) every coin gets fetched on its own which is sloww.... --- coinmanager/coinc/models.py | 2 +- coinmanager/coinc/templates/coinc/coin.html | 2 +- .../coinc/templates/coinc/country.html | 3 ++ coinmanager/coinc/templates/coinc/year.html | 14 ++---- coinmanager/coinc/urls.py | 2 +- coinmanager/coinc/views.py | 40 +++++++++++++----- coinmanager/db.sqlite3 | Bin 188416 -> 188416 bytes 7 files changed, 38 insertions(+), 25 deletions(-) diff --git a/coinmanager/coinc/models.py b/coinmanager/coinc/models.py index 735f70a..411ec46 100644 --- a/coinmanager/coinc/models.py +++ b/coinmanager/coinc/models.py @@ -54,7 +54,7 @@ class Country(Model): class Stamp(Model): - name_short = CharField('Prägung', max_length=10) + name_short = CharField('Prägung', max_length=10, primary_key=True) name = CharField('Name', max_length=50) diff --git a/coinmanager/coinc/templates/coinc/coin.html b/coinmanager/coinc/templates/coinc/coin.html index fa72b40..3a5113c 100644 --- a/coinmanager/coinc/templates/coinc/coin.html +++ b/coinmanager/coinc/templates/coinc/coin.html @@ -1 +1 @@ -
{% if coin.found %}x{% endif %}
+
{% if coin.found_by %}x{% endif %}
diff --git a/coinmanager/coinc/templates/coinc/country.html b/coinmanager/coinc/templates/coinc/country.html index b4aa8d6..a1c72b3 100644 --- a/coinmanager/coinc/templates/coinc/country.html +++ b/coinmanager/coinc/templates/coinc/country.html @@ -1,3 +1,5 @@ + {% include "base.html" %} + {% block content %} @@ -15,3 +17,4 @@ {% endfor %}
+ {% endblock %} diff --git a/coinmanager/coinc/templates/coinc/year.html b/coinmanager/coinc/templates/coinc/year.html index e842c2a..f6bde03 100644 --- a/coinmanager/coinc/templates/coinc/year.html +++ b/coinmanager/coinc/templates/coinc/year.html @@ -1,17 +1,9 @@ {% for stamp in year %}
{{ stamp }}{{ year_int }}
- - - - - - - - - - - + {% for value in values %} + {% show_coin country year_int stamp value %} + {% endfor %} {% endfor %} {% ifnotequal year|length 1 %} diff --git a/coinmanager/coinc/urls.py b/coinmanager/coinc/urls.py index f49c441..9da2336 100644 --- a/coinmanager/coinc/urls.py +++ b/coinmanager/coinc/urls.py @@ -27,5 +27,5 @@ app_name = 'coinc' urlpatterns = [ path('', views.IndexView.as_view(), name='index'), path('statistik', views.statistic, name='statistic'), - path('', views.DetailView.as_view(), name='country'), + path('', views.detail_country, name='country'), ] diff --git a/coinmanager/coinc/views.py b/coinmanager/coinc/views.py index 2c532dd..def3459 100644 --- a/coinmanager/coinc/views.py +++ b/coinmanager/coinc/views.py @@ -39,10 +39,11 @@ class IndexView(generic.ListView): -class DetailView(generic.DetailView): - model = Country - template_name = 'coinc/country.html' - +def detail_country(request, country): + template = loader.get_template('coinc/country.html') + c = Country.objects.get(name_iso=country) + return HttpResponse(template.render(show_country(c), request)) +# return HttpResponse(template.render("foo", request)) @register.inclusion_tag('coinc/navigation.html') @@ -50,7 +51,6 @@ def show_navigation(countrys): return {'countrys': countrys} - @register.inclusion_tag('coinc/country.html') def show_country(country): c = { @@ -63,10 +63,6 @@ def show_country(country): irregular_stamps = {} stamps = Stamp.objects.filter(country=country.name_iso).values( 'name_short', 'years') - coins = Coin.objects.filter(country=country.name_iso).values( - 'value', 'year', 'stamp', 'name', 'found_by', - 'found_on', 'buy_only', 'circulation', 'comment', - 'in_collector', 'checked', 'exists') if stamps: temp_stamps = {} @@ -108,8 +104,30 @@ def show_country(country): @register.inclusion_tag('coinc/year.html') def show_year(country, year): - return { 'year': country['years'][year], - 'year_int': year } + return { + 'year': country['years'][year], + 'year_int': year, + 'values': [1, 2, 5, 10, 20, 50, 100, 200, 201, 202, 203], + 'country': country['name_iso'] + } + + +@register.inclusion_tag('coinc/coin.html') +def show_coin(country, year, stamp, value): + ''' @param country: Country.name_iso + @param year: int YYYY + @param stamp: stamp_id + @param value: int e [1,2,5,10,20,50,100,200,201,202,203] + ''' + coin = Coin.objects.filter(country=country, year=year, stamp=stamp, value=value).values( + 'value', 'year', 'stamp', 'name', 'found_by', + 'found_on', 'buy_only', 'circulation', 'comment', + 'in_collector', 'checked', 'exists') + + if coin: + print(coin) + + return { 'coin': coin } # TODO diff --git a/coinmanager/db.sqlite3 b/coinmanager/db.sqlite3 index ebae7aeec7457a0feedc1533c0f1825e6159cd15..6f372e6ab72a1ceee0eeb133f703277d7c9e2f66 100644 GIT binary patch delta 1355 zcmZWpYiJx*6rOwTJa%Sx=4MUfWD{B@kG2U(_PyQR#A2gqqFEABe8dN3ce=YIX}h~| zo1~;knoKA~jbcm0i%O+G3QEE18tMMhL`v~b(b7K^T4JFO6va@aB56QpHpT{e;huBv z;XJ-`?m2g6$v(4WKUM7E-|$FC@+p>=G}}3uPWwToo@Dj5%>S;Nlpy zsXdt+$|k*DZzOJ=;zvgG%&_0<_qKS0E&hn+i?#-Xt%0CB=nn@Y(Y8v{sO^8Fa9kf9 z$;B;wZ_po!`+dRSW5zzeI~)l3qk%Sclkq}F)e=`}BRwqnmGqD#StK8kIr0UWBvBGB z7}bO)pOHys%lvN7c0Q(ZIDqK=XHYpW$ttc9=MB$JAV1BY_qZF(be$V1mv{xj9+Wz$ zX9sfe%+Nqy9~sJJkGQ__vU_+$RvEIo;2d5d0>fdasHbLUF3uoUD~l=Z4Ec-PC%-8R z%I8Wuec~+2pswQavuIIva2O$oSrm5{doG|N!ZGD-Dtw9NvGSfmeF@ZAIQ6M4u~as3i*@#PVSOra(%&>xI`Lx>_h{3-eRdV zx6asghSwQbuv6)adjM&onJ^+Z8FJI~e~on1qA~`7Q?9XrY_o|r#H55fdg{@u>?{LW z5Eut{k5QhI|B(mn@7VWo_v}@UTQ)|RB;(3jQ5%LczzPCxEEwDIj@fN-L9MGpC-8`V z;BdOsGV7hP>DWlW8-=aZKL!`5V+`u(&_U$j8XYH@(bL8o*g#1-JqYSHaMMLIR?8>J;f8yTO6E%cac>?!Q2yR zdV37~sEN9#!9_hs!GjGpMgKkyC$`9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