diff --git a/coinmanager/coinc/templates/coinc/index.html b/coinmanager/coinc/templates/coinc/index.html new file mode 100644 index 0000000..b22ea36 --- /dev/null +++ b/coinmanager/coinc/templates/coinc/index.html @@ -0,0 +1,57 @@ + + + + + + Münzsammlung + + {% if countrys %} {% for country in countrys %} + + + + + + + + {% for year in countrys|years:country %} + + {% comment %} + {% for col in row.cols %} + + {% endfor %} + + + + + + + {% endcomment %} + {% endfor %} + +
{{ countrys|name:country }} + x €
{{ year }}{{ col.x }}{% col.special1_name %}{% col.special1_x %}{% col.special2_name %}{% col.special2_x %}{% col.special3_name %}{% col.special3_x %}
{% endfor %} {% else %} +

Trage zuerst Länder im Adminbereich ein.

{% endif %} + + diff --git a/coinmanager/coinc/views.py b/coinmanager/coinc/views.py index 1f6ddc3..b01dd54 100644 --- a/coinmanager/coinc/views.py +++ b/coinmanager/coinc/views.py @@ -15,14 +15,90 @@ # # You should have received a copy of the GNU General Public License # along with this program. If not, see . +# +# +# Views +# - / +# coinc Homepage: Übersicht wie in der Tabelle +# Template: index.? lädt country.? nach und ermöglicht Filtern danach +# +# - / kann 'de' oder 'deutschland' sein +# Landesansicht: Zeige nur ein Land wie in der Übersicht +# Template: country.? +# - Urlaubsansicht /?urlaub +# Ansicht von einem Land, wobei nur die Münzen, die Fehlen hervorgehoben werden +# +# - /statistik +# Statistik: zeige Statistiken, z.B. Anwachsen der Münzen über die Zeit/Länder/etc. +# Template: statistik.? +# +# - /admin +# Adminbereich: Füge neue Länder hinzu +# Template: bereits vorhanden -from django.shortcuts import render - from django.http import HttpResponse +from django.template import loader +from django.template.defaultfilters import register +from .models import Country + + + +@register.filter(name='name') +def name(countrys, name_iso): + return countrys[name_iso]['name'] + + +@register.filter(name='years') +def years(countrys, name_iso): + return countrys[name_iso]['years'] def index(request): - return HttpResponse("loift") + c = Country.objects.order_by('name') + + template = loader.get_template('coinc/index.html') + countrys = {} + import json + from datetime import datetime + year_now = datetime.now().year + + for country in c: + countrys[country.name_iso] = { + 'name': country.name, + 'comment': country.comment, + 'euro_member_since': country.euro_member_since, + 'years': {} + } + + for year in range(country.euro_member_since, year_now + 1): + countrys[country.name_iso]['years'][year] = { + '1': 1, + '2': 2, + '5': 5, + '10': 10, + '20': 20, + '50': 50, + '100': 100, + '200': 200, + '200_1_name': 'name 1', + '200_1': 200, + '200_2_name': 'name 2', + '200_2': 200, + '200_3_name': 'name 3', + '200_3': 200 + } + + context = { 'countrys': countrys } + print(json.dumps(context, indent=4)) + return HttpResponse(template.render(context, request)) + + +def country(request, country): + return HttpResponse(f"Land: {country}") + + +def statistic(request): + return HttpResponse('Statistik') diff --git a/coinmanager/db.sqlite3 b/coinmanager/db.sqlite3 index a1780d9..e395e3f 100644 Binary files a/coinmanager/db.sqlite3 and b/coinmanager/db.sqlite3 differ