This commit is contained in:
koksnuss 2020-06-25 12:52:49 +02:00
parent c7dc1f1390
commit 9ec8bcab87
2 changed files with 97 additions and 89 deletions

View File

@ -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 %}
<tr>
<td class="spacer" colspan="12"></td>
</tr>{% endifnotequal %}
{% 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 %}

View File

@ -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,15 +126,79 @@ 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)
coins = Coin.objects.all().filter(country=country)
for coin in coins:
td_class = ''
if not coin.exists:
td_class = 'noexist'
elif coin.buy_only:
td_class = 'buy_only'
elif coin.circulation and coin.circulation <= 1500000:
td_class = 'rare'
elif coin.value in [10, 20, 50]:
td_class = 'brass'
elif coin.found_by:
td_class = 'found'
else:
td_class = 'exist'
if coin.in_collector:
td_class += ' ec'
elif coin.checked:
td_class += ' checked'
div_class = ''
marker = ''
if coin.found_by:
div_class = f"found {coin.found_by}"
marker = ''
name = coin.name if coin.name else ''
special_class = ''
special_name = ''
if name:
if coin.value == 201:
special_name = 'special1_name'
elif coin.value == 202:
special_name = 'special2_name'
elif coin.value == 203:
special_name = 'special3_name'
if len(name) >= 18 and len(name) <= 42:
special_class = 'two_lines'
elif len(name) > 42:
special_class = 'three_lines'
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,
'div_class': div_class,
'special_class': special_class,
'special_name': special_name
}
return {
'country': c,
@ -146,94 +211,27 @@ def show_country(country, single_country=False):
@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']
'stamps': country['years'][year],
'year_short': year[2:4],
}
@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:
def show_coin(coin, value):
''' show a coin '''
if coin:
return {
'value': value,
'marker': 'Fehler!'
'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'],
}
td_class = ''
if not coin.exists:
td_class = 'noexist'
elif coin.buy_only:
td_class = 'buy_only'
elif coin.circulation and coin.circulation <= 1500000:
td_class = 'rare'
elif coin.value in [10, 20, 50]:
td_class = 'brass'
elif coin.found_by:
td_class = 'found'
else:
td_class = 'exist'
if coin.in_collector:
td_class += ' ec'
elif coin.checked:
td_class += ' checked'
div_class = ''
marker = ''
if coin.found_by:
div_class = f"found {coin.found_by}"
marker = ''
name = coin.name if coin.name else ''
special_class = ''
special_name = ''
if name:
if value == 201:
special_name = 'special1_name'
elif value == 202:
special_name = 'special2_name'
elif value == 203:
special_name = 'special3_name'
if len(name) >= 18 and len(name) <= 42:
special_class = 'two_lines'
elif len(name) > 42:
special_class = 'three_lines'
return {
'value': value,
'marker': marker,
'name': name,
'td_class': td_class,
'div_class': div_class,
'special_class': special_class,
'special_name': special_name
}
return {}
def add_user(request, username, color):