diff --git a/coinmanager/coinc/templates/coinc/country.html b/coinmanager/coinc/templates/coinc/country.html
new file mode 100644
index 0000000..7d5c629
--- /dev/null
+++ b/coinmanager/coinc/templates/coinc/country.html
@@ -0,0 +1,24 @@
+
+
+
+ {{ country.name }} |
+ | x € |
+ |
+
+
+ {% for year in country.years %}
+
+ {{ year }} | {% comment %}
+ {% for col in row.cols %}
+ {{ col.x }} |
+ {% endfor %}
+ {% col.special1_name %} |
+ {% col.special1_x %} |
+ {% col.special2_name %} |
+ {% col.special2_x %} |
+ {% col.special3_name %} |
+ {% col.special3_x %} |
+ {% endcomment %}
+
{% endfor %}
+
+
diff --git a/coinmanager/coinc/templates/coinc/index.html b/coinmanager/coinc/templates/coinc/index.html
index b22ea36..765a9d3 100644
--- a/coinmanager/coinc/templates/coinc/index.html
+++ b/coinmanager/coinc/templates/coinc/index.html
@@ -17,41 +17,14 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see .
-
-https://stackoverflow.com/questions/49548972/django-remove-all-empty-lines-from-template-output
-
-
-->
Münzsammlung
- {% if countrys %} {% for country in countrys %}
-
-
-
- {{ countrys|name:country }} |
- | x € |
- |
-
-
- {% for year in countrys|years:country %}
-
- {{ year }} | {% comment %}
- {% for col in row.cols %}
- {{ col.x }} |
- {% endfor %}
- {% col.special1_name %} |
- {% col.special1_x %} |
- {% col.special2_name %} |
- {% col.special2_x %} |
- {% col.special3_name %} |
- {% col.special3_x %} |
- {% endcomment %}
-
{% endfor %}
-
-
{% endfor %} {% else %}
- Trage zuerst Länder im Adminbereich ein.
{% endif %}
+ {% if countrys %} {% for country in countrys %}
+{% show_country country %} {% endfor %} {% else %}
+ Trage zuerst Länder im Adminbereich ein.
{% endif %}
diff --git a/coinmanager/coinc/views.py b/coinmanager/coinc/views.py
index b01dd54..912ee74 100644
--- a/coinmanager/coinc/views.py
+++ b/coinmanager/coinc/views.py
@@ -15,29 +15,11 @@
#
# 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 datetime import datetime
+
from django.http import HttpResponse
from django.template import loader
from django.template.defaultfilters import register
@@ -46,53 +28,12 @@ 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):
- c = Country.objects.order_by('name')
-
+ countrys = Country.objects.order_by('name')
template = loader.get_template('coinc/index.html')
- countrys = {}
- import json
- from datetime import datetime
year_now = datetime.now().year
+ context = {'countrys': countrys}
- 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))
@@ -100,5 +41,37 @@ def country(request, country):
return HttpResponse(f"Land: {country}")
+@register.inclusion_tag('coinc/country.html')
+def show_country(country):
+ year_now = datetime.now().year
+ c = {
+ 'name_iso': 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):
+ c['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
+ }
+
+ return {'country': c}
+
+
def statistic(request):
return HttpResponse('Statistik')