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]
|
[packages]
|
||||||
django = "*"
|
django = "*"
|
||||||
|
pudb = "*"
|
||||||
|
|
||||||
[requires]
|
[requires]
|
||||||
python_version = "3.6"
|
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>
|
<th colspan="2">x €</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>{% for stamp in country.stamps %}
|
<tbody>
|
||||||
{% show_stamp stamp %}{% endfor %}
|
{% for year in country.years %}
|
||||||
|
{% show_year country year %}
|
||||||
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
@ -1,38 +1,10 @@
|
|||||||
<!DOCTYPE html>
|
{% extends "base.html" %}
|
||||||
<!--
|
{% block content %}
|
||||||
|
|
||||||
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>
|
|
||||||
{% if countrys %}
|
{% if countrys %}
|
||||||
{% navigation countrys %}
|
{% show_navigation countrys %}
|
||||||
{% for country in countrys %}
|
{% for country in countrys %}
|
||||||
{% show_country country %}
|
{% show_country country %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>Trage zuerst Länder im Adminbereich ein.</p>{% endif %}
|
<p>Trage zuerst Länder im Adminbereich ein.</p>{% endif %}
|
||||||
</body>
|
{% endblock %}
|
||||||
</html>
|
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
{% for year in country.years %}
|
|
||||||
{% show_year year %}{% endfor %}
|
|
@ -1,5 +1,16 @@
|
|||||||
|
{% for stamp in year %}
|
||||||
<tr>
|
<tr>
|
||||||
<td class="year">
|
<td class="year"><div class="">{{ stamp }}{{ year_int }}</div></td>
|
||||||
<div class="{{ year.complete }}">{{ year.short }}</div></td>{% for coin in year.coins %}
|
<td></td>
|
||||||
{% show_coin coin %}{% endfor %}
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
@ -25,7 +25,7 @@ from . import views
|
|||||||
|
|
||||||
app_name = 'coinc'
|
app_name = 'coinc'
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('', views.index, name='index'),
|
path('', views.IndexView.as_view(), name='index'),
|
||||||
path('statistik', views.statistic, name='statistic'),
|
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.http import HttpResponse
|
||||||
from django.template import loader
|
from django.template import loader
|
||||||
from django.template.defaultfilters import register
|
from django.template.defaultfilters import register
|
||||||
|
from django.views import generic
|
||||||
|
|
||||||
from .models import Country
|
from .models import Country, Stamp
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def index(request):
|
class IndexView(generic.ListView):
|
||||||
countrys = Country.objects.order_by('name')
|
template_name = 'coinc/index.html'
|
||||||
template = loader.get_template('coinc/index.html')
|
context_object_name = 'countrys'
|
||||||
year_now = datetime.now().year
|
|
||||||
context = {'countrys': 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')
|
@register.inclusion_tag('coinc/navigation.html')
|
||||||
def navigation(countrys):
|
def show_navigation(countrys):
|
||||||
return {'countrys': countrys}
|
return {'countrys': countrys}
|
||||||
|
|
||||||
|
|
||||||
@ -51,6 +55,12 @@ def coins(country, year):
|
|||||||
return country['years'][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')
|
@register.inclusion_tag('coinc/country.html')
|
||||||
def show_country(country):
|
def show_country(country):
|
||||||
year_now = datetime.now().year
|
year_now = datetime.now().year
|
||||||
@ -58,25 +68,42 @@ def show_country(country):
|
|||||||
'name_iso': country.name_iso,
|
'name_iso': country.name_iso,
|
||||||
'name': country.name,
|
'name': country.name,
|
||||||
'comment': country.comment,
|
'comment': country.comment,
|
||||||
'euro_member_since': country.euro_member_since,
|
|
||||||
'years': {}
|
'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):
|
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]
|
y = str(year)[2:4]
|
||||||
c['years'][y] = {
|
c['years'][y] = {}
|
||||||
'1': 'x',
|
for stamp in stamps_per_year:
|
||||||
'2': '',
|
c['years'][y][stamp] = {'name': stamp}
|
||||||
'5': '',
|
if country.name_iso == 'gr' or country.name_iso == 'de':
|
||||||
'10': '',
|
print(c)
|
||||||
'20': 'x',
|
|
||||||
'50': '',
|
|
||||||
'100': '',
|
|
||||||
'200': 'x',
|
|
||||||
'201': '',
|
|
||||||
'202': '',
|
|
||||||
'203': ''
|
|
||||||
}
|
|
||||||
|
|
||||||
return {'country': c}
|
return {'country': c}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user