up
This commit is contained in:
parent
cb4789dc01
commit
66f19c436b
@ -10,7 +10,7 @@
|
||||
{{ country.name }}{% if country.comment %}
|
||||
<small> - {{ country.comment }}</small>{% endif %}
|
||||
</div>
|
||||
<div class="float-right">{{ total_coins }}</div>
|
||||
<div class="float-right">{{ coin_sum }}</div>
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -1,7 +1,7 @@
|
||||
{% include 'header.html' with title='Münzsammlung' %}
|
||||
{% if countrys %}
|
||||
<p><h5>Gesamtwert {{ coin_sum }}</h5></p>
|
||||
{% include 'coinc/filter_country.html' with countrys=countrys %}
|
||||
{% else %}
|
||||
<p>Trage zuerst Länder im Adminbereich ein.</p>{% endif %}
|
||||
<small>Version 200531</small>
|
||||
{% include 'footer.html' with title='Münzsammlung' %}
|
||||
|
@ -1,2 +1,3 @@
|
||||
<span class="badge badge-pill badge-light">Version 200531</span>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -27,15 +27,39 @@ from django.template.defaultfilters import register
|
||||
from .models import Country, Stamp, Coin, User
|
||||
|
||||
|
||||
def total_coin_sum():
|
||||
total_coin_sum = 0
|
||||
for country in Country.objects.order_by('name'):
|
||||
total_coin_sum += coin_sum_of_(country)
|
||||
return total_coin_sum
|
||||
|
||||
|
||||
def coin_sum_of_(country):
|
||||
coin_count = {'total': 0}
|
||||
for value in [1, 2, 5, 10, 20, 50, 100, 200, 201, 202, 203]:
|
||||
coin_count[value] = Coin.objects.filter(
|
||||
country=country,
|
||||
value=value
|
||||
).exclude(found_by__isnull=True).count()
|
||||
if value > 200:
|
||||
coin_count['total'] += 200 * coin_count[value]
|
||||
else:
|
||||
coin_count['total'] += value * coin_count[value]
|
||||
coin_count['total'] /= 100
|
||||
return coin_count['total']
|
||||
|
||||
|
||||
def index(request):
|
||||
''' index view '''
|
||||
|
||||
template = loader.get_template('coinc/index.html')
|
||||
countrys = Country.objects.order_by('name')
|
||||
users = User.objects.order_by('id')
|
||||
coin_sum = total_coin_sum()
|
||||
context = {
|
||||
'countrys': countrys,
|
||||
'users': users
|
||||
'users': users,
|
||||
'coin_sum': f"{coin_sum:.2f} €"
|
||||
}
|
||||
|
||||
return HttpResponse(template.render(context, request))
|
||||
@ -108,24 +132,13 @@ def show_country(country, single_country=False):
|
||||
|
||||
stamps_per_year = {}
|
||||
|
||||
|
||||
coin_count = {'total': 0}
|
||||
for value in [1, 2, 5, 10, 20, 50, 100, 200, 201, 202, 203]:
|
||||
coin_count[value] = Coin.objects.filter(
|
||||
country=country,
|
||||
value=value
|
||||
).exclude(found_by__isnull=True).count()
|
||||
if value > 200:
|
||||
coin_count['total'] += 200 * coin_count[value]
|
||||
else:
|
||||
coin_count['total'] += value * coin_count[value]
|
||||
coin_count['total'] /= 100
|
||||
coin_sum = coin_sum_of_(country)
|
||||
|
||||
return {
|
||||
'country': c,
|
||||
'single_country': single_country,
|
||||
'users': User.objects.order_by('id').values('name','color'),
|
||||
'total_coins': f"{coin_count['total']:.2f} €"
|
||||
'coin_sum': f"{coin_sum:.2f} €"
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user