add original colors, move logic out of coin.html into views.py

This commit is contained in:
koksnuss 2020-04-29 11:48:26 +02:00
parent 83b59f4f04
commit 47a23da02c
4 changed files with 71 additions and 26 deletions

View File

@ -83,23 +83,31 @@ td > * {
} }
table > tbody > tr > td { table > tbody > tr > td {
background-color: lightgray; background-color: #b7b7b7;
}
table > tbody > tr > td > div.coin {
position: relative;
height: 30px;
width: 30px;
text-align: inherit;
line-height: 30px;
} }
td.noexist { td.noexist {
background-color: gray; background-color: #434343;
} }
td.brass { td.brass {
background-color: yellow; background-color: #ffff99;
} }
td.rare { td.rare {
background-color: brown; background-color: #e69138;
} }
td.kms { td.buy_only {
background-color: red; background-color: #dd7e6b;
} }
td.year { td.year {
@ -107,7 +115,7 @@ td.year {
} }
td.year-complete { td.year-complete {
background-color: green; background-color: #00ff00;
} }
td.spacer { td.spacer {
@ -115,20 +123,24 @@ td.spacer {
background-color: white; background-color: white;
} }
div.ec { td.in_collector {
color: red; color: #ff0000;
font-weight: bold;
} }
div.check { td.checked {
color: green; color: #00ff00;
font-weight: bold;
} }
div.found { div.found {
position: absolute;
top: 0;
height:30px; height:30px;
width:30px; width:30px;
clip-path: polygon(100% 70%, 100% 100%, 70% 100%); clip-path: polygon(100% 70%, 100% 100%, 70% 100%);
} }
div.moritz { div.Moritz {
background-color: red; background-color: red;
} }

View File

@ -1 +1 @@
<td class="{{ coin.kms }} {{ coin.rare }} {{ coin.noexist }} {{ coin.brass }}"><div class="{{ coin.found }} {{ coin.found_by }} {{ coin.ec }} {{ coin.check }}">{% if coin.found_by %}x{% endif %}</div></td> <td class="{{ td_class }}"><div class="coin">{{ marker }}<div class="{{ div_class }}"></div></div></td>

View File

@ -1,6 +1,6 @@
{% for stamp in year %} <tr> {% for stamp in year %} <tr>
<td class="year"><div class="">{{ stamp }}{{ year_int }}</div></td> <td class="year"><div class="">{{ stamp }}{{ year_short }}</div></td>
{% for value in values %}{% show_coin country year_int stamp value %}{% endfor %} </tr>{% endfor %}{% ifnotequal year|length 1 %} {% for value in values %}{% show_coin country year_short stamp value %}{% endfor %} </tr>{% endfor %}{% ifnotequal year|length 1 %}
<tr> <tr>
<td class="spacer" colspan="12"></td> <td class="spacer" colspan="12"></td>
</tr>{% endifnotequal %} </tr>{% endifnotequal %}

View File

@ -86,17 +86,21 @@ def show_country(country):
year_now = datetime.now().year year_now = datetime.now().year
for year in [str(i) for i in range(country.euro_member_since, year_now + 1)]: 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 and year in irregular_stamps: if irregular_stamps and year in irregular_stamps:
for irregular_stamp, value in irregular_stamps[year].items(): for irregular_stamp, value in irregular_stamps[year].items():
stamps_per_year[irregular_stamp] = {} stamps_per_year[irregular_stamp] = {}
# TODO this is not really a fix... # TODO this is not really a fix...
elif country.name_iso == 'gr': elif country.name_iso == 'gr':
stamps_per_year = {'': {}} stamps_per_year = {'': {}}
y = year[2:4] year_short = year[2:4]
c['years'][y] = {} c['years'][year_short] = {}
for stamp in stamps_per_year: for stamp in stamps_per_year:
c['years'][y][stamp] = {'name': stamp} c['years'][year_short][stamp] = {'name': stamp}
stamps_per_year = {} stamps_per_year = {}
return {'country': c} return {'country': c}
@ -107,7 +111,7 @@ def show_country(country):
def show_year(country, year): def show_year(country, year):
return { return {
'year': country['years'][year], 'year': country['years'][year],
'year_int': year, 'year_short': year,
'values': [1, 2, 5, 10, 20, 50, 100, 200, 201, 202, 203], 'values': [1, 2, 5, 10, 20, 50, 100, 200, 201, 202, 203],
'country': country['name_iso'] 'country': country['name_iso']
} }
@ -121,15 +125,44 @@ def show_coin(country, year, stamp, value):
@param stamp: stamp_id @param stamp: stamp_id
@param value: int e [1,2,5,10,20,50,100,200,201,202,203] @param value: int e [1,2,5,10,20,50,100,200,201,202,203]
''' '''
coin = Coin.objects.filter(country=country, year=year, stamp=stamp, value=value).values( # TODO: fix this before the end of 2098
'value', 'year', 'stamp', 'name', 'found_by', year = int(year)
'found_on', 'buy_only', 'circulation', 'comment', if year == 99:
'in_collector', 'checked', 'exists') year += 1900
else:
year += 2000
if coin: if stamp == "":
print(coin) stamp = None
return { 'coin': coin } try:
coin = Coin.objects.get(country=country, year=year, stamp=stamp, value=value)
except Coin.DoesNotExist:
return {}
if coin.buy_only:
td_class = 'buy_only'
elif coin.circulation and coin.circulation < 1500000:
td_class = 'rare'
elif coin.noexist:
td_class = 'noexist'
elif coin.value in [10, 20, 50]:
td_class = 'brass'
if coin.in_collector:
td_class += ' in_collector'
elif coin.checked:
td_class += ' coin_checked'
if coin.found_by:
div_class = f"found {coin.found_by}"
marker = 'x'
return {
'marker': marker,
'td_class': td_class,
'div_class': div_class,
}