Merge branch 'master' of ssh://willipink.eu:3456/moritz/coinmanager into HEAD

This commit is contained in:
koksnuss 2020-06-25 13:59:52 +02:00
commit fc790c178f
3 changed files with 98 additions and 90 deletions

View File

@ -1,6 +1,6 @@
# Roadmap # Roadmap
- [x] Prototype - [x] Prototype
- [ ] Milestone [1.0 Happy Birthday](https://willipink.eu/git/moritz/coinmanager/milestone/23) - [x] Milestone [1.0 Happy Birthday](https://willipink.eu/git/moritz/coinmanager/milestone/23)
- [ ] Milestone [2.0 Nice to have](https://willipink.eu/git/moritz/coinmanager/milestone/24) - [ ] Milestone [2.0 Nice to have](https://willipink.eu/git/moritz/coinmanager/milestone/24)
- [ ] Add statistics [#5](https://willipink.eu/git/moritz/coinmanager/issues/5) - [ ] Add statistics [#5](https://willipink.eu/git/moritz/coinmanager/issues/5)
- [ ] Add search function [#8](https://willipink.eu/git/moritz/coinmanager/issues/8) - [ ] Add search function [#8](https://willipink.eu/git/moritz/coinmanager/issues/8)

View File

@ -1,6 +1,16 @@
{% for stamp in year %} <tr name="{{ year_short }}" stamp="{{ stamp }}"> {% for stamp, coins in stamps.items %}
<td class="year {{ year_complete }}"><div class="coin">{{ stamp }}{{ year_short }}</div></td> <tr name="{{ year_short }}" stamp="{{ stamp }}">
{% for value in values %}{% show_coin country year_short stamp value %}{% endfor %} </tr>{% endfor %}{% ifnotequal year|length 1 %} <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> <tr>
<td class="spacer" colspan="12"></td> <td class="spacer" colspan="12"></td>
</tr>{% endifnotequal %} </tr>
{% endifnotequal %}

View File

@ -90,6 +90,7 @@ def show_country(country, single_country=False):
'comment': country.comment, 'comment': country.comment,
'years': {} 'years': {}
} }
coin_sum = coin_sum_of_(country)
irregular_stamps = {} irregular_stamps = {}
stamps = Stamp.objects.filter(country=country.name_iso).values( 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': elif country.name_iso == 'gr':
stamps_per_year = {'': {}} stamps_per_year = {'': {}}
year_short = year[2:4] c['years'][year] = {}
c['years'][year_short] = {}
for stamp in stamps_per_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 = {} stamps_per_year = {}
coin_sum = coin_sum_of_(country) coins = Coin.objects.all().filter(country=country)
for coin in coins:
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!'
}
td_class = '' td_class = ''
if not coin.exists: if not coin.exists:
@ -213,11 +177,11 @@ def show_coin(country, year, stamp, value):
special_class = '' special_class = ''
special_name = '' special_name = ''
if name: if name:
if value == 201: if coin.value == 201:
special_name = 'special1_name' special_name = 'special1_name'
elif value == 202: elif coin.value == 202:
special_name = 'special2_name' special_name = 'special2_name'
elif value == 203: elif coin.value == 203:
special_name = 'special3_name' special_name = 'special3_name'
if len(name) >= 18 and len(name) <= 42: if len(name) >= 18 and len(name) <= 42:
@ -225,8 +189,9 @@ def show_coin(country, year, stamp, value):
elif len(name) > 42: elif len(name) > 42:
special_class = 'three_lines' special_class = 'three_lines'
return { stamp = coin.stamp.name_short if coin.stamp else ''
'value': value,
c['years'][str(coin.year)][stamp][coin.value] = {
'marker': marker, 'marker': marker,
'name': name, 'name': name,
'td_class': td_class, 'td_class': td_class,
@ -235,6 +200,39 @@ def show_coin(country, year, stamp, value):
'special_name': special_name '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): def add_user(request, username, color):
''' add a user ''' ''' add a user '''