Release 16 (devel -> main) #39

Merged
ChaoticByte merged 13 commits from devel into main 2023-04-17 19:10:52 +00:00
6 changed files with 30 additions and 25 deletions
Showing only changes of commit ac59aa0baa - Show all commits

View file

@ -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, ' (',
product_name,
' (',
content_litres::real, -- converting to real removes trailing zeros
'l) x ', amount) as "text",
'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

View file

@ -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):

View file

@ -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;
}

View file

@ -1,5 +1,5 @@
{% if global_message != "" %}
<div class="flex flex-center globalmessage">
<div class="flex flex-center globalmessage text-align-center">
<div>{{ global_message }}</div>
</div>
{% endif %}

View file

@ -11,13 +11,13 @@
{% if history %}
<table class="history">
<tr>
<th>{% translate "last 30 actions" %}</th>
<th></th>
<th colspan="3">{% translate "last 30 actions" %}</th>
</tr>
{% for h in history %}
<tr>
<td>{{ h.0 }}</td>
<td class="historydate">{{ h.1 }}</td>
<td class="text-align-right">{{ h.0 }} {{ currency_suffix }}</td>
<td>{{ h.1 }}</td>
<td>{{ h.2 }}</td>
</tr>
{% endfor %}
</table>

View file

@ -2,14 +2,14 @@
{% load static %}
<div class="flex flex-center userpanel">
<div class="userinfo">
<div class="userinfo text-align-center">
<img src="/profilepictures/{{ user.profile_picture_filename|urlencode }}"><span>{% if user.first_name != "" %}
{{ user.first_name }} {{ user.last_name }} ({{ user.username }}){% else %}{{ user.username }}{% endif %}
&nbsp;-&nbsp;
{% if user.balance < 0.01 %}
<span class="userbalancewarn">{% translate "Balance" %}: {{ user.balance }}{{ currency_suffix }}</span>
<span class="userbalancewarn">{% translate "Balance" %}: {{ user.balance }} {{ currency_suffix }}</span>
{% else %}
<span>{% translate "Balance" %}: {{ user.balance }}{{ currency_suffix }}</span>
<span>{% translate "Balance" %}: {{ user.balance }} {{ currency_suffix }}</span>
{% endif %}
</span>
</div>