From f5bf77fbed69ed262a92b37ef441de847fa7cef6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20M=C3=BCller?= <9070224-W13R@users.noreply.gitlab.com> Date: Sat, 6 Aug 2022 17:33:31 +0200 Subject: [PATCH 1/3] Added auto-reload after 2 minutes when logged in, to force auto-logout --- application/app/templates/deposit.html | 1 + application/app/templates/history.html | 2 ++ application/app/templates/index.html | 2 ++ application/app/templates/order.html | 2 ++ application/app/templates/statistics.html | 2 ++ static/js/autoreload.js | 3 +++ 6 files changed, 12 insertions(+) create mode 100644 static/js/autoreload.js diff --git a/application/app/templates/deposit.html b/application/app/templates/deposit.html index 1093070..dac6950 100644 --- a/application/app/templates/deposit.html +++ b/application/app/templates/deposit.html @@ -35,5 +35,6 @@ + {% endblock %} diff --git a/application/app/templates/history.html b/application/app/templates/history.html index cdfa78f..ff43b23 100644 --- a/application/app/templates/history.html +++ b/application/app/templates/history.html @@ -32,5 +32,7 @@ {% else %} {% translate "No history." %} {% endif %} + + {% endblock %} diff --git a/application/app/templates/index.html b/application/app/templates/index.html index c639390..9836e32 100644 --- a/application/app/templates/index.html +++ b/application/app/templates/index.html @@ -44,4 +44,6 @@ {% endif %} + + {% endblock %} diff --git a/application/app/templates/order.html b/application/app/templates/order.html index 2f1d58f..5c72755 100644 --- a/application/app/templates/order.html +++ b/application/app/templates/order.html @@ -97,4 +97,6 @@ {% endif %} + + {% endblock %} diff --git a/application/app/templates/statistics.html b/application/app/templates/statistics.html index 9d26016..cc340fd 100644 --- a/application/app/templates/statistics.html +++ b/application/app/templates/statistics.html @@ -146,4 +146,6 @@ + + {% endblock %} diff --git a/static/js/autoreload.js b/static/js/autoreload.js new file mode 100644 index 0000000..0c30078 --- /dev/null +++ b/static/js/autoreload.js @@ -0,0 +1,3 @@ +setInterval(() => { + location.reload(); +}, 1000*60*2); // reload after 2 minutes \ No newline at end of file From ca160781dd6702aacae1f0d91b8bfb9b6c87df01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20M=C3=BCller?= <9070224-W13R@users.noreply.gitlab.com> Date: Sat, 6 Aug 2022 18:56:39 +0200 Subject: [PATCH 2/3] Added support for profile pictures --- application/app/admin.py | 11 +++++--- application/app/models.py | 1 + .../app/templates/registration/login.html | 24 ++++++++-------- application/app/templates/userPanel.html | 26 +++++++++-------- static/css/login.css | 22 ++++++++++----- static/css/main.css | 11 ++++++-- static/profilepictures/default.svg | 28 +++++++++++++++++++ 7 files changed, 88 insertions(+), 35 deletions(-) create mode 100644 static/profilepictures/default.svg diff --git a/application/app/admin.py b/application/app/admin.py index 66b072a..7e81374 100644 --- a/application/app/admin.py +++ b/application/app/admin.py @@ -45,10 +45,13 @@ class CustomUserAdmin(UserAdmin): fieldsets_ = list((*UserAdmin.fieldsets,)) fieldsets_.insert(1, ( - "Balance", - {"fields": ("balance", "allow_order_with_negative_balance")}, - ) - ) + "Balance", + {"fields": ("balance", "allow_order_with_negative_balance")}, + )) + fieldsets_.insert(2, ( + "Profile Picture", + {"fields": ("profile_picture_filename",)}, + )) fieldsets = tuple(fieldsets_) list_display = ["username", "balance", "is_active", "allow_order_with_negative_balance"] diff --git a/application/app/models.py b/application/app/models.py index 7ce9370..370a0dd 100644 --- a/application/app/models.py +++ b/application/app/models.py @@ -20,6 +20,7 @@ class User(AbstractUser): balance = models.DecimalField(max_digits=8, decimal_places=2, default=0.00) allow_order_with_negative_balance = models.BooleanField(default=False) + profile_picture_filename = models.CharField(default="default.svg", max_length=25) def delete(self, *args, **kwargs): self.balance = 0 diff --git a/application/app/templates/registration/login.html b/application/app/templates/registration/login.html index 32b6ab0..af1f25c 100644 --- a/application/app/templates/registration/login.html +++ b/application/app/templates/registration/login.html @@ -2,6 +2,7 @@ {% extends "baseLayout.html" %} {% load i18n %} +{% load static %} {% block title %} {% translate "Drinks - Login" %} @@ -68,19 +69,20 @@ diff --git a/application/app/templates/userPanel.html b/application/app/templates/userPanel.html index eecaf88..b634cd3 100644 --- a/application/app/templates/userPanel.html +++ b/application/app/templates/userPanel.html @@ -1,18 +1,22 @@ {% load i18n %} +{% load static %}
- {% if user.first_name != "" %} - {% translate "User" %}: {{ user.first_name }} {{ user.last_name }} ({{ user.username }}) - {% else %} - {% translate "User" %}: {{ user.username }} - {% endif %} -  -  - {% if user.balance < 0.01 %} - {% translate "Balance" %}: {{ user.balance }}{{ currency_suffix }} - {% else %} - {% translate "Balance" %}: {{ user.balance }}{{ currency_suffix }} - {% endif %} + + + {% if user.first_name != "" %} + {% translate "User" %}: {{ user.first_name }} {{ user.last_name }} ({{ user.username }}) + {% else %} + {% translate "User" %}: {{ user.username }} + {% endif %} +  -  + {% if user.balance < 0.01 %} + {% translate "Balance" %}: {{ user.balance }}{{ currency_suffix }} + {% else %} + {% translate "Balance" %}: {{ user.balance }}{{ currency_suffix }} + {% endif %} +
Home diff --git a/static/css/login.css b/static/css/login.css index 346b4f9..6414c2d 100644 --- a/static/css/login.css +++ b/static/css/login.css @@ -25,14 +25,27 @@ main > h1 { justify-content: center; align-items: center; } -.userlist li { +.userlist > li { display: flex; width: 100%; align-items: center; justify-content: center; - padding: .8rem 1.1rem; margin-bottom: .5rem; + padding: 0 .5rem; +} +.userlist > li > img { + margin-right: auto; + margin-left: 0; + height: 2rem; + width: 2rem; +} +.userlist > li > div { + display: flex; + flex-grow: 1; + align-items: center; + justify-content: center; text-align: center; + padding: .8rem 1.1rem; } .userlistButton { font-size: 1.1rem; @@ -102,11 +115,6 @@ form .horizontalButtonList { .userlist { width: 100%; } - .userlist li { - width: 100%; - padding-left: 0; - padding-right: 0; - } .pinpad table tr td button { height: 4.2rem; width: 4.2rem; diff --git a/static/css/main.css b/static/css/main.css index fbc5d2a..c9cb878 100644 --- a/static/css/main.css +++ b/static/css/main.css @@ -67,10 +67,17 @@ main { align-items: center; margin-top: 1rem; font-size: 1rem; - width: 90%; + width: 94%; } -.userInfo span { +.userInfo > span { font-size: 1.1rem; + vertical-align: middle; +} +.userInfo > img { + vertical-align: middle; + width: 1.8rem; + height: 1.8rem; + margin: .5rem; } .userPanel > .horizontalButtonList { margin-left: auto; diff --git a/static/profilepictures/default.svg b/static/profilepictures/default.svg new file mode 100644 index 0000000..7138ef3 --- /dev/null +++ b/static/profilepictures/default.svg @@ -0,0 +1,28 @@ + + + + + + + + + + From 80b407069db12904f23191bc1df6f437a2f4356b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20M=C3=BCller?= <9070224-W13R@users.noreply.gitlab.com> Date: Sat, 6 Aug 2022 18:58:43 +0200 Subject: [PATCH 3/3] Bump version to 12 --- lib/env.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/env.sh b/lib/env.sh index ba983e8..8781ef1 100644 --- a/lib/env.sh +++ b/lib/env.sh @@ -2,5 +2,5 @@ export DJANGO_SK_ABS_FP="$(pwd)/config/secret_key.txt" export STATIC_FILES="$(pwd)/static/" -export APP_VERSION="11" +export APP_VERSION="12" export PYTHONPATH="$(pwd)/packages/"