add feature /<countr.name_iso> now works :)

every coin gets fetched on its own which is sloww....
This commit is contained in:
koksnuss 2020-04-29 00:19:42 +02:00
parent a070b7e97d
commit 683f926ed6
7 changed files with 38 additions and 25 deletions

View File

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

View File

@ -1 +1 @@
<td class="{{ coin.kms }} {{ coin.rare }} {{ coin.noexist }} {{ coin.brass }}"><div class="{{ coin.found }} {{ coin.found_by }} {{ coin.ec }} {{ coin.check }}">{% if coin.found %}x{% endif %}</div></td>
<td class="{{ coin.kms }} {{ coin.rare }} {{ coin.noexist }} {{ coin.brass }}"><div class="{{ coin.found }} {{ coin.found_by }} {{ coin.ec }} {{ coin.check }}">{% if coin.found_by %}x{% endif %}</div></td>

View File

@ -1,3 +1,5 @@
{% include "base.html" %}
{% block content %}
<table>
<thead>
<tr>
@ -15,3 +17,4 @@
{% endfor %}
</tbody>
</table>
{% endblock %}

View File

@ -1,17 +1,9 @@
{% for stamp in year %}
<tr>
<td class="year"><div class="">{{ stamp }}{{ year_int }}</div></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
{% for value in values %}
{% show_coin country year_int stamp value %}
{% endfor %}
</tr>
{% endfor %}
{% ifnotequal year|length 1 %}

View File

@ -27,5 +27,5 @@ app_name = 'coinc'
urlpatterns = [
path('', views.IndexView.as_view(), name='index'),
path('statistik', views.statistic, name='statistic'),
path('<str:country>', views.DetailView.as_view(), name='country'),
path('<str:country>', views.detail_country, name='country'),
]

View File

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

Binary file not shown.