fix #6
This commit is contained in:
parent
c7dc1f1390
commit
9ec8bcab87
@ -1,6 +1,16 @@
|
||||
{% for stamp in year %} <tr name="{{ year_short }}" stamp="{{ stamp }}">
|
||||
<td class="year {{ year_complete }}"><div class="coin">{{ stamp }}{{ year_short }}</div></td>
|
||||
{% for value in values %}{% show_coin country year_short stamp value %}{% endfor %} </tr>{% endfor %}{% ifnotequal year|length 1 %}
|
||||
{% for stamp, coins in stamps.items %}
|
||||
<tr name="{{ year_short }}" stamp="{{ stamp }}">
|
||||
<td class="year {{ year_complete }}">
|
||||
<div class="coin">{{ stamp }}{{ year_short }}</div>
|
||||
</td>
|
||||
{% for value, coin in coins.items %}
|
||||
{% show_coin coin value %}
|
||||
{% endfor %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
{% ifnotequal stamps|length 1 %}
|
||||
<tr>
|
||||
<td class="spacer" colspan="12"></td>
|
||||
</tr>{% endifnotequal %}
|
||||
</tr>
|
||||
{% endifnotequal %}
|
||||
|
@ -90,6 +90,7 @@ def show_country(country, single_country=False):
|
||||
'comment': country.comment,
|
||||
'years': {}
|
||||
}
|
||||
coin_sum = coin_sum_of_(country)
|
||||
|
||||
irregular_stamps = {}
|
||||
stamps = Stamp.objects.filter(country=country.name_iso).values(
|
||||
@ -125,64 +126,27 @@ def show_country(country, single_country=False):
|
||||
elif country.name_iso == 'gr':
|
||||
stamps_per_year = {'': {}}
|
||||
|
||||
year_short = year[2:4]
|
||||
c['years'][year_short] = {}
|
||||
c['years'][year] = {}
|
||||
|
||||
for stamp in stamps_per_year:
|
||||
c['years'][year_short][stamp] = {'name': stamp}
|
||||
c['years'][year][stamp] = {
|
||||
1: {},
|
||||
2: {},
|
||||
5: {},
|
||||
10: {},
|
||||
20: {},
|
||||
50: {},
|
||||
100: {},
|
||||
200: {},
|
||||
201: {},
|
||||
202: {},
|
||||
203: {}
|
||||
}
|
||||
|
||||
stamps_per_year = {}
|
||||
|
||||
coin_sum = coin_sum_of_(country)
|
||||
|
||||
return {
|
||||
'country': c,
|
||||
'single_country': single_country,
|
||||
'users': User.objects.order_by('id').values('name','color'),
|
||||
'coin_sum': f"{coin_sum:.2f} €"
|
||||
}
|
||||
|
||||
|
||||
@register.inclusion_tag('coinc/year.html')
|
||||
def show_year(country, year):
|
||||
''' show a year '''
|
||||
|
||||
return {
|
||||
'year': country['years'][year],
|
||||
'year_short': year,
|
||||
'values': [1, 2, 5, 10, 20, 50, 100, 200, 201, 202, 203],
|
||||
'country': country['name_iso']
|
||||
}
|
||||
|
||||
|
||||
@register.inclusion_tag('coinc/coin.html')
|
||||
def show_coin(country, year, stamp, value):
|
||||
''' show a coin
|
||||
@param country: Country.name_iso
|
||||
@param year: int YYYY
|
||||
@param stamp: stamp_id
|
||||
@param value: int e [1,2,5,10,20,50,100,200,201,202,203]
|
||||
'''
|
||||
year = int(year) # TODO fix this before the end of 2098
|
||||
if year == 99:
|
||||
year += 1900
|
||||
else:
|
||||
year += 2000
|
||||
|
||||
if stamp == "":
|
||||
stamp = None
|
||||
|
||||
try:
|
||||
coin = Coin.objects.get(country=country, year=year, stamp=stamp, value=value)
|
||||
except Coin.DoesNotExist:
|
||||
return {
|
||||
'value': value
|
||||
}
|
||||
except Coin.MultipleObjectsReturned:
|
||||
return {
|
||||
'value': value,
|
||||
'marker': 'Fehler!'
|
||||
}
|
||||
coins = Coin.objects.all().filter(country=country)
|
||||
for coin in coins:
|
||||
|
||||
td_class = ''
|
||||
if not coin.exists:
|
||||
@ -213,11 +177,11 @@ def show_coin(country, year, stamp, value):
|
||||
special_class = ''
|
||||
special_name = ''
|
||||
if name:
|
||||
if value == 201:
|
||||
if coin.value == 201:
|
||||
special_name = 'special1_name'
|
||||
elif value == 202:
|
||||
elif coin.value == 202:
|
||||
special_name = 'special2_name'
|
||||
elif value == 203:
|
||||
elif coin.value == 203:
|
||||
special_name = 'special3_name'
|
||||
|
||||
if len(name) >= 18 and len(name) <= 42:
|
||||
@ -225,8 +189,9 @@ def show_coin(country, year, stamp, value):
|
||||
elif len(name) > 42:
|
||||
special_class = 'three_lines'
|
||||
|
||||
return {
|
||||
'value': value,
|
||||
stamp = coin.stamp.name_short if coin.stamp else ''
|
||||
|
||||
c['years'][str(coin.year)][stamp][coin.value] = {
|
||||
'marker': marker,
|
||||
'name': name,
|
||||
'td_class': td_class,
|
||||
@ -235,6 +200,39 @@ def show_coin(country, year, stamp, value):
|
||||
'special_name': special_name
|
||||
}
|
||||
|
||||
return {
|
||||
'country': c,
|
||||
'single_country': single_country,
|
||||
'users': User.objects.order_by('id').values('name','color'),
|
||||
'coin_sum': f"{coin_sum:.2f} €"
|
||||
}
|
||||
|
||||
|
||||
@register.inclusion_tag('coinc/year.html')
|
||||
def show_year(country, year):
|
||||
''' show a year '''
|
||||
return {
|
||||
'stamps': country['years'][year],
|
||||
'year_short': year[2:4],
|
||||
}
|
||||
|
||||
|
||||
@register.inclusion_tag('coinc/coin.html')
|
||||
def show_coin(coin, value):
|
||||
''' show a coin '''
|
||||
if coin:
|
||||
return {
|
||||
'value': value,
|
||||
'marker': coin['marker'],
|
||||
'name': coin['name'],
|
||||
'td_class': coin['td_class'],
|
||||
'div_class': coin['div_class'],
|
||||
'special_class': coin['special_class'],
|
||||
'special_name': coin['special_name'],
|
||||
}
|
||||
else:
|
||||
return {}
|
||||
|
||||
|
||||
def add_user(request, username, color):
|
||||
''' add a user '''
|
||||
|
Loading…
x
Reference in New Issue
Block a user