use str(year), minify code, add NOT A FIX TODO!!! this will blow up when more stamps with special years will be added...
This commit is contained in:
parent
1a0158258c
commit
1e2982b60d
@ -63,7 +63,6 @@ def show_year(country, 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
|
|
||||||
c = {
|
c = {
|
||||||
'name_iso': country.name_iso,
|
'name_iso': country.name_iso,
|
||||||
'name': country.name,
|
'name': country.name,
|
||||||
@ -76,8 +75,10 @@ def show_country(country):
|
|||||||
|
|
||||||
if stamps:
|
if stamps:
|
||||||
temp_stamps = {}
|
temp_stamps = {}
|
||||||
|
|
||||||
for stamp in stamps:
|
for stamp in stamps:
|
||||||
stamp_name_short = stamp['name_short']
|
stamp_name_short = stamp['name_short']
|
||||||
|
|
||||||
if stamp['years'] == "":
|
if stamp['years'] == "":
|
||||||
temp_stamps[stamp_name_short] = {}
|
temp_stamps[stamp_name_short] = {}
|
||||||
else:
|
else:
|
||||||
@ -85,25 +86,26 @@ def show_country(country):
|
|||||||
irregular_stamps[year] = {}
|
irregular_stamps[year] = {}
|
||||||
irregular_stamps[year][stamp_name_short] = {}
|
irregular_stamps[year][stamp_name_short] = {}
|
||||||
temp_stamps[''] = {}
|
temp_stamps[''] = {}
|
||||||
|
|
||||||
stamps = temp_stamps
|
stamps = temp_stamps
|
||||||
else:
|
else:
|
||||||
stamps = {'': {}}
|
stamps = {'': {}}
|
||||||
|
|
||||||
for year in range(country.euro_member_since, year_now + 1):
|
year_now = datetime.now().year
|
||||||
|
for year in [str(i) for i in range(country.euro_member_since, year_now + 1)]:
|
||||||
stamps_per_year = stamps
|
stamps_per_year = stamps
|
||||||
if irregular_stamps:
|
if irregular_stamps and year in irregular_stamps:
|
||||||
print(irregular_stamps)
|
for irregular_stamp, value in irregular_stamps[year].items():
|
||||||
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] = {}
|
stamps_per_year[irregular_stamp] = {}
|
||||||
|
# TODO this is not really a fix...
|
||||||
|
elif country.name_iso == 'gr':
|
||||||
|
stamps_per_year = {'': {}}
|
||||||
|
|
||||||
y = str(year)[2:4]
|
y = year[2:4]
|
||||||
c['years'][y] = {}
|
c['years'][y] = {}
|
||||||
for stamp in stamps_per_year:
|
for stamp in stamps_per_year:
|
||||||
c['years'][y][stamp] = {'name': stamp}
|
c['years'][y][stamp] = {'name': stamp}
|
||||||
if country.name_iso == 'gr' or country.name_iso == 'de':
|
stamps_per_year = {}
|
||||||
print(c)
|
|
||||||
|
|
||||||
return {'country': c}
|
return {'country': c}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user