From c53d9e4cfdff234b7fea25f8bf9f9b4380647270 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20M=C3=BCnch?= Date: Mon, 17 Jan 2022 23:22:04 +0100 Subject: [PATCH] fix #46: update webinterface to distinguish between last found coins and last checked coins --- coinmanager/coinc/templates/coinc/index.html | 10 +++++----- coinmanager/coinc/views.py | 15 +++++++++++---- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/coinmanager/coinc/templates/coinc/index.html b/coinmanager/coinc/templates/coinc/index.html index 6655410..1ed9d8c 100644 --- a/coinmanager/coinc/templates/coinc/index.html +++ b/coinmanager/coinc/templates/coinc/index.html @@ -3,12 +3,12 @@
Gesamtwert {{ coin_sum }}
{% include 'coinc/filter_country.html' with countrys=countrys %}
Zuletzt gefunden
- {% for coin in recent_coins %} - {% if coin.exists %} - {% if coin.found_by %} + {% for coin in found_coins %} +

{{ coin.found_on|date:"d.m.Y" }}: {{ coin.value|floatformat:2 }} € {{ coin.year }}{% if coin.stamp %}-{{ coin.stamp }}{% endif %}{% if coin.name %} "{{ coin.name }}"{% endif %} aus {{ coin.country}} von {{ coin.found_by }}

+ {% endfor %} +
Zuletzt überprüft und einsortiert
+ {% for coin in checked_coins %}

{{ coin.found_on|date:"d.m.Y" }}: {{ coin.value|floatformat:2 }} € {{ coin.year }}{% if coin.stamp %}-{{ coin.stamp }}{% endif %}{% if coin.name %} "{{ coin.name }}"{% endif %} aus {{ coin.country}} von {{ coin.found_by }}

- {% endif %} - {% endif %} {% endfor %} {% else %}

Trage zuerst Länder im Adminbereich ein.

diff --git a/coinmanager/coinc/views.py b/coinmanager/coinc/views.py index d4125e5..0f80173 100644 --- a/coinmanager/coinc/views.py +++ b/coinmanager/coinc/views.py @@ -40,14 +40,21 @@ def index(request): countrys = Country.objects.order_by('name') users = User.objects.order_by('id') coin_sum = total_coin_sum() - recent_coins = Coin.objects.order_by('-found_on')[:10] - for coin in range(len(recent_coins)): - recent_coins[coin].value /= 100 + found_coins = Coin.objects.order_by('-found_on').exclude( + exists=False).exclude( + 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 = { 'countrys': countrys, 'users': users, 'coin_sum': f'{coin_sum:.2f} €', - 'recent_coins': recent_coins, + 'found_coins': found_coins, + 'checked_coins': checked_coins } return HttpResponse(template.render(context, request))