diff --git a/app/db_queries.py b/app/db_queries.py index c10b85e..656bbda 100644 --- a/app/db_queries.py +++ b/app/db_queries.py @@ -2,6 +2,7 @@ from django.conf import settings from django.db import connection +from django.utils.translation import gettext COMBINE_ALPHABET = "abcdefghijklmnopqrstuvwxyz" @@ -44,11 +45,13 @@ def select_history(user, language_code="en") -> list: user_id = user.pk result = _db_select(f""" select + price_sum as "sum", concat( - price_sum, '{settings.CURRENCY_SUFFIX} - ', - product_name, ' (', - content_litres::real, -- converting to real removes trailing zeros - 'l) x ', amount) as "text", + product_name, + ' (', + content_litres::real, -- converting to real removes trailing zeros + 'l) x ', amount + ) as "text", datetime from app_order where user_id = {user_id} @@ -56,7 +59,8 @@ def select_history(user, language_code="en") -> list: union select - concat(transaction_sum, '{settings.CURRENCY_SUFFIX} - Deposit') as "text", + transaction_sum as "sum", + '{gettext("Deposit")}' as "text", datetime from app_userdeposits_view where user_id = {user_id} @@ -64,7 +68,8 @@ def select_history(user, language_code="en") -> list: union select - concat(transaction_sum, '{settings.CURRENCY_SUFFIX} - ', comment) as "text", + transaction_sum as "sum", + comment as "text", datetime from app_registertransaction where user_id = {user_id} and is_transfer = true @@ -73,9 +78,6 @@ def select_history(user, language_code="en") -> list: fetch first 30 rows only; """) result = [list(row) for row in result] - if language_code == "de": # reformat for german translation - for row in result: - row[0] = row[0].replace(".", ",") return result diff --git a/app/models.py b/app/models.py index 842f889..681a433 100644 --- a/app/models.py +++ b/app/models.py @@ -44,7 +44,7 @@ class Drink(models.Model): super().save() def __str__(self): - return f"{self.product_name} ({float(self.content_litres):.2f}l) - {self.price}{settings.CURRENCY_SUFFIX}" + return f"{self.product_name} ({float(self.content_litres):.2f}l) - {self.price} {settings.CURRENCY_SUFFIX}" class RegisterTransaction(models.Model): @@ -86,7 +86,7 @@ class RegisterTransaction(models.Model): self.user.save() super().delete(*args, kwargs) - def __str__(self): return f"{self.transaction_sum}{settings.CURRENCY_SUFFIX} by {self.user}" + def __str__(self): return f"{self.transaction_sum} {settings.CURRENCY_SUFFIX} by {self.user}" class Order(models.Model): @@ -134,7 +134,7 @@ class Order(models.Model): drink.save() super().delete(*args, **kwargs) - def __str__(self): return f"{self.drink.product_name} ({float(self.drink.content_litres):.2f}l) x {self.amount} - {self.price_sum}{settings.CURRENCY_SUFFIX}" + def __str__(self): return f"{self.drink.product_name} ({float(self.drink.content_litres):.2f}l) x {self.amount} - {self.price_sum} {settings.CURRENCY_SUFFIX}" class Global(models.Model): diff --git a/app/static/css/main.css b/app/static/css/main.css index 338fb35..2abaa0d 100644 --- a/app/static/css/main.css +++ b/app/static/css/main.css @@ -127,7 +127,6 @@ th { .globalmessage > div { width: 96%; - text-align: center; word-break: keep-all; word-wrap: break-word; box-sizing: border-box; @@ -140,10 +139,6 @@ th { gap: 1rem; } -.userinfo { - text-align: center; -} - .userinfo > span { vertical-align: middle; } @@ -232,6 +227,14 @@ main { flex-wrap: wrap; } +.text-align-right { + text-align: right; +} + +.text-align-center { + text-align: center; +} + .gap-1rem { gap: 1rem; } diff --git a/app/templates/globalmessage.html b/app/templates/globalmessage.html index 9b33850..4ec0067 100644 --- a/app/templates/globalmessage.html +++ b/app/templates/globalmessage.html @@ -1,5 +1,5 @@ {% if global_message != "" %} -
+
{{ global_message }}
{% endif %} \ No newline at end of file diff --git a/app/templates/history.html b/app/templates/history.html index 89d689a..c94f17e 100644 --- a/app/templates/history.html +++ b/app/templates/history.html @@ -11,13 +11,13 @@ {% if history %} - - + {% for h in history %} - - + + + {% endfor %}
{% translate "last 30 actions" %}{% translate "last 30 actions" %}
{{ h.0 }}{{ h.1 }}{{ h.0 }} {{ currency_suffix }}{{ h.1 }}{{ h.2 }}
diff --git a/app/templates/userpanel.html b/app/templates/userpanel.html index 4423150..a436a98 100644 --- a/app/templates/userpanel.html +++ b/app/templates/userpanel.html @@ -2,14 +2,14 @@ {% load static %}
-
+
{% if user.first_name != "" %} {{ user.first_name }} {{ user.last_name }} ({{ user.username }}){% else %}{{ user.username }}{% endif %}  -  {% if user.balance < 0.01 %} - {% translate "Balance" %}: {{ user.balance }}{{ currency_suffix }} + {% translate "Balance" %}: {{ user.balance }} {{ currency_suffix }} {% else %} - {% translate "Balance" %}: {{ user.balance }}{{ currency_suffix }} + {% translate "Balance" %}: {{ user.balance }} {{ currency_suffix }} {% endif %}