fix #46: update webinterface to distinguish between last found coins and last checked coins

This commit is contained in:
Moritz Münch 2022-01-17 23:22:04 +01:00
parent 9c92a6ecf3
commit c53d9e4cfd
2 changed files with 16 additions and 9 deletions

View File

@ -3,12 +3,12 @@
<h5>Gesamtwert {{ coin_sum }}</h5> <h5>Gesamtwert {{ coin_sum }}</h5>
{% include 'coinc/filter_country.html' with countrys=countrys %} {% include 'coinc/filter_country.html' with countrys=countrys %}
<h5>Zuletzt gefunden</h5> <h5>Zuletzt gefunden</h5>
{% for coin in recent_coins %} {% for coin in found_coins %}
{% if coin.exists %} <p>{{ coin.found_on|date:"d.m.Y" }}: {{ coin.value|floatformat:2 }} &euro; {{ coin.year }}{% if coin.stamp %}-{{ coin.stamp }}{% endif %}{% if coin.name %} "{{ coin.name }}"{% endif %} aus {{ coin.country}} von {{ coin.found_by }}</p>
{% if coin.found_by %} {% endfor %}
<h5>Zuletzt überprüft und einsortiert</h5>
{% for coin in checked_coins %}
<p>{{ coin.found_on|date:"d.m.Y" }}: {{ coin.value|floatformat:2 }} &euro; {{ coin.year }}{% if coin.stamp %}-{{ coin.stamp }}{% endif %}{% if coin.name %} "{{ coin.name }}"{% endif %} aus {{ coin.country}} von {{ coin.found_by }}</p> <p>{{ coin.found_on|date:"d.m.Y" }}: {{ coin.value|floatformat:2 }} &euro; {{ coin.year }}{% if coin.stamp %}-{{ coin.stamp }}{% endif %}{% if coin.name %} "{{ coin.name }}"{% endif %} aus {{ coin.country}} von {{ coin.found_by }}</p>
{% endif %}
{% endif %}
{% endfor %} {% endfor %}
{% else %} {% else %}
<p>Trage zuerst Länder im Adminbereich ein.</p> <p>Trage zuerst Länder im Adminbereich ein.</p>

View File

@ -40,14 +40,21 @@ def index(request):
countrys = Country.objects.order_by('name') countrys = Country.objects.order_by('name')
users = User.objects.order_by('id') users = User.objects.order_by('id')
coin_sum = total_coin_sum() coin_sum = total_coin_sum()
recent_coins = Coin.objects.order_by('-found_on')[:10] found_coins = Coin.objects.order_by('-found_on').exclude(
for coin in range(len(recent_coins)): exists=False).exclude(
recent_coins[coin].value /= 100 found_by__exact=None)[:10]
checked_coins = Coin.objects.order_by('-date_modified').filter(
checked=True)[:10]
for coin in range(len(found_coins)):
found_coins[coin].value /= 100
for coin in range(len(checked_coins)):
checked_coins[coin].value /= 100
context = { context = {
'countrys': countrys, 'countrys': countrys,
'users': users, 'users': users,
'coin_sum': f'{coin_sum:.2f}', 'coin_sum': f'{coin_sum:.2f}',
'recent_coins': recent_coins, 'found_coins': found_coins,
'checked_coins': checked_coins
} }
return HttpResponse(template.render(context, request)) return HttpResponse(template.render(context, request))