make gui work again. show stamps! :)) greece still has errors
This commit is contained in:
parent
104d96f02c
commit
e675c02ec2
1
Pipfile
1
Pipfile
@ -7,6 +7,7 @@ verify_ssl = true
|
||||
|
||||
[packages]
|
||||
django = "*"
|
||||
pudb = "*"
|
||||
|
||||
[requires]
|
||||
python_version = "3.6"
|
||||
|
32
coinmanager/coinc/templates/base.html
Normal file
32
coinmanager/coinc/templates/base.html
Normal file
@ -0,0 +1,32 @@
|
||||
<!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/>.
|
||||
|
||||
-->
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Münzsammlung</title> {% load static %}
|
||||
<link rel="stylesheet" type="text/css" href="{% static 'coinc/bootstrap.min.css' %}">
|
||||
<link rel="stylesheet" type="text/css" href="{% static 'coinc/styles.css' %}">
|
||||
</head>
|
||||
<body>
|
||||
{% block content %}{% endblock %}
|
||||
</body>
|
||||
</html>
|
@ -9,7 +9,9 @@
|
||||
<th colspan="2">x €</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>{% for stamp in country.stamps %}
|
||||
{% show_stamp stamp %}{% endfor %}
|
||||
<tbody>
|
||||
{% for year in country.years %}
|
||||
{% show_year country year %}
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
@ -1,38 +1,10 @@
|
||||
<!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/>.
|
||||
|
||||
-->
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Münzsammlung</title> {% load static %}
|
||||
<link rel="stylesheet" type="text/css" href="{% static 'coinc/bootstrap.min.css' %}">
|
||||
<link rel="stylesheet" type="text/css" href="{% static 'coinc/styles.css' %}">
|
||||
</head>
|
||||
<body>
|
||||
{% extends "base.html" %}
|
||||
{% block content %}
|
||||
{% if countrys %}
|
||||
{% navigation countrys %}
|
||||
{% show_navigation countrys %}
|
||||
{% for country in countrys %}
|
||||
{% show_country country %}
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<p>Trage zuerst Länder im Adminbereich ein.</p>{% endif %}
|
||||
</body>
|
||||
</html>
|
||||
{% endblock %}
|
||||
|
@ -1,2 +0,0 @@
|
||||
{% for year in country.years %}
|
||||
{% show_year year %}{% endfor %}
|
@ -1,5 +1,16 @@
|
||||
{% for stamp in year %}
|
||||
<tr>
|
||||
<td class="year">
|
||||
<div class="{{ year.complete }}">{{ year.short }}</div></td>{% for coin in year.coins %}
|
||||
{% show_coin coin %}{% endfor %}
|
||||
<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>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
@ -25,7 +25,7 @@ from . import views
|
||||
|
||||
app_name = 'coinc'
|
||||
urlpatterns = [
|
||||
path('', views.index, name='index'),
|
||||
path('', views.IndexView.as_view(), name='index'),
|
||||
path('statistik', views.statistic, name='statistic'),
|
||||
path('<str:country>', views.country, name='country'),
|
||||
path('<str:country>', views.DetailView.as_view(), name='country'),
|
||||
]
|
||||
|
@ -23,26 +23,30 @@ from datetime import datetime
|
||||
from django.http import HttpResponse
|
||||
from django.template import loader
|
||||
from django.template.defaultfilters import register
|
||||
from django.views import generic
|
||||
|
||||
from .models import Country
|
||||
from .models import Country, Stamp
|
||||
|
||||
|
||||
|
||||
def index(request):
|
||||
countrys = Country.objects.order_by('name')
|
||||
template = loader.get_template('coinc/index.html')
|
||||
year_now = datetime.now().year
|
||||
context = {'countrys': countrys}
|
||||
class IndexView(generic.ListView):
|
||||
template_name = 'coinc/index.html'
|
||||
context_object_name = 'countrys'
|
||||
|
||||
return HttpResponse(template.render(context, request))
|
||||
def get_queryset(self):
|
||||
''' return all countries ordered by name '''
|
||||
return Country.objects.order_by('name_iso')
|
||||
|
||||
|
||||
def country(request, country):
|
||||
return HttpResponse(f"Land: {country}")
|
||||
|
||||
class DetailView(generic.DetailView):
|
||||
model = Country
|
||||
template_name = 'coinc/country.html'
|
||||
|
||||
|
||||
|
||||
@register.inclusion_tag('coinc/navigation.html')
|
||||
def navigation(countrys):
|
||||
def show_navigation(countrys):
|
||||
return {'countrys': countrys}
|
||||
|
||||
|
||||
@ -51,6 +55,12 @@ def coins(country, year):
|
||||
return country['years'][year]
|
||||
|
||||
|
||||
@register.inclusion_tag('coinc/year.html')
|
||||
def show_year(country, year):
|
||||
return { 'year': country['years'][year],
|
||||
'year_int': year }
|
||||
|
||||
|
||||
@register.inclusion_tag('coinc/country.html')
|
||||
def show_country(country):
|
||||
year_now = datetime.now().year
|
||||
@ -58,25 +68,42 @@ def show_country(country):
|
||||
'name_iso': country.name_iso,
|
||||
'name': country.name,
|
||||
'comment': country.comment,
|
||||
'euro_member_since': country.euro_member_since,
|
||||
'years': {}
|
||||
}
|
||||
|
||||
irregular_stamps = {}
|
||||
stamps = Stamp.objects.filter(country=country.name_iso).values('name_short', 'years')
|
||||
|
||||
if stamps:
|
||||
temp_stamps = {}
|
||||
for stamp in stamps:
|
||||
stamp_name_short = stamp['name_short']
|
||||
if stamp['years'] == "":
|
||||
temp_stamps[stamp_name_short] = {}
|
||||
else:
|
||||
for year in stamp['years'].split(","):
|
||||
irregular_stamps[year] = {}
|
||||
irregular_stamps[year][stamp_name_short] = {}
|
||||
temp_stamps[''] = {}
|
||||
stamps = temp_stamps
|
||||
else:
|
||||
stamps = {'': {}}
|
||||
|
||||
for year in range(country.euro_member_since, year_now + 1):
|
||||
stamps_per_year = stamps
|
||||
if irregular_stamps:
|
||||
print(irregular_stamps)
|
||||
if str(year) in irregular_stamps:
|
||||
print(f"{year} in!")
|
||||
for irregular_stamp, value in irregular_stamps[str(year)].items():
|
||||
stamps_per_year[irregular_stamp] = {}
|
||||
|
||||
y = str(year)[2:4]
|
||||
c['years'][y] = {
|
||||
'1': 'x',
|
||||
'2': '',
|
||||
'5': '',
|
||||
'10': '',
|
||||
'20': 'x',
|
||||
'50': '',
|
||||
'100': '',
|
||||
'200': 'x',
|
||||
'201': '',
|
||||
'202': '',
|
||||
'203': ''
|
||||
}
|
||||
c['years'][y] = {}
|
||||
for stamp in stamps_per_year:
|
||||
c['years'][y][stamp] = {'name': stamp}
|
||||
if country.name_iso == 'gr' or country.name_iso == 'de':
|
||||
print(c)
|
||||
|
||||
return {'country': c}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user