fill out euro_member_since to db; add iterate through countrys and years
This commit is contained in:
parent
927ba9262c
commit
2f9c9539db
57
coinmanager/coinc/templates/coinc/index.html
Normal file
57
coinmanager/coinc/templates/coinc/index.html
Normal file
@ -0,0 +1,57 @@
|
||||
<!DOCTYPE html>
|
||||
<!--
|
||||
|
||||
Copyright (C) 2020 willipink.eu
|
||||
Author Moritz Münch moritzmuench@mailbox.org
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
https://stackoverflow.com/questions/49548972/django-remove-all-empty-lines-from-template-output
|
||||
|
||||
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Münzsammlung</title>
|
||||
</head>
|
||||
<body> {% if countrys %} {% for country in countrys %}
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<td colspan="4"><a href="/coinc/{{ country }}">{{ countrys|name:country }}</a><td>
|
||||
<td colspan="2">x €</td>
|
||||
<td colspan="9"></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody> {% for year in countrys|years:country %}
|
||||
<tr>
|
||||
<td>{{ year }}</td>{% comment %}
|
||||
{% for col in row.cols %}
|
||||
<td>{{ col.x }}</td>
|
||||
{% endfor %}
|
||||
<td>{% col.special1_name %}</td>
|
||||
<td>{% col.special1_x %}</td>
|
||||
<td>{% col.special2_name %}</td>
|
||||
<td>{% col.special2_x %}</td>
|
||||
<td>{% col.special3_name %}</td>
|
||||
<td>{% col.special3_x %}</td>
|
||||
{% endcomment %}
|
||||
</tr> {% endfor %}
|
||||
</tbody>
|
||||
</table> {% endfor %} {% else %}
|
||||
<p>Trage zuerst Länder im Adminbereich ein.</p> {% endif %}
|
||||
</body>
|
||||
</html>
|
@ -15,14 +15,90 @@
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#
|
||||
# Views
|
||||
# - /
|
||||
# coinc Homepage: Übersicht wie in der Tabelle
|
||||
# Template: index.? lädt country.? nach und ermöglicht Filtern danach
|
||||
#
|
||||
# - /<country> <country> kann 'de' oder 'deutschland' sein
|
||||
# Landesansicht: Zeige nur ein Land wie in der Übersicht
|
||||
# Template: country.?
|
||||
# - Urlaubsansicht /<country>?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')
|
||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user