diff --git a/coinmanager/coinc/static/coinc/styles.css b/coinmanager/coinc/static/coinc/styles.css index 359316e..3345fe8 100644 --- a/coinmanager/coinc/static/coinc/styles.css +++ b/coinmanager/coinc/static/coinc/styles.css @@ -190,6 +190,10 @@ thead > tr:first-child > th { cursor: w-resize; } +thead div.total_coins { + float:right; +} + thead > tr:nth-child(2) > th { background-color: white; top: 40px; diff --git a/coinmanager/coinc/templates/coinc/country.html b/coinmanager/coinc/templates/coinc/country.html index c769691..9203a05 100644 --- a/coinmanager/coinc/templates/coinc/country.html +++ b/coinmanager/coinc/templates/coinc/country.html @@ -10,6 +10,7 @@ {{ country.name }}{% if country.comment %} - {{ country.comment }}{% endif %} +
{{ total_coins }}
diff --git a/coinmanager/coinc/views.py b/coinmanager/coinc/views.py index 5d74970..29f700a 100644 --- a/coinmanager/coinc/views.py +++ b/coinmanager/coinc/views.py @@ -108,10 +108,26 @@ 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 + import json + print(json.dumps(coin_count, indent=4)) + return { 'country': c, 'single_country': single_country, - 'users': User.objects.order_by('id').values('name','color') + 'users': User.objects.order_by('id').values('name','color'), + 'total_coins': f"{coin_count['total']:.2f} €" }