diff --git a/coinmanager/coinc/views.py b/coinmanager/coinc/views.py index b666458..69d00ce 100644 --- a/coinmanager/coinc/views.py +++ b/coinmanager/coinc/views.py @@ -63,7 +63,6 @@ def show_year(country, year): @register.inclusion_tag('coinc/country.html') def show_country(country): - year_now = datetime.now().year c = { 'name_iso': country.name_iso, 'name': country.name, @@ -76,8 +75,10 @@ def show_country(country): if stamps: temp_stamps = {} + for stamp in stamps: stamp_name_short = stamp['name_short'] + if stamp['years'] == "": temp_stamps[stamp_name_short] = {} else: @@ -85,25 +86,26 @@ def show_country(country): 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): + 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 - 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] = {} + if irregular_stamps and year in irregular_stamps: + for irregular_stamp, value in irregular_stamps[year].items(): + 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] = {} for stamp in stamps_per_year: c['years'][y][stamp] = {'name': stamp} - if country.name_iso == 'gr' or country.name_iso == 'de': - print(c) + stamps_per_year = {} return {'country': c}