Compare commits

..

No commits in common. "main" and "16" have entirely different histories.
main ... 16

40 changed files with 282 additions and 466 deletions

2
.gitignore vendored
View file

@ -1,7 +1,7 @@
/data/* /data/*
/data/logs/* /data/logs/*
/data/tls/* /data/tls/*
/data/django_static/* /data/static/*
/data/profilepictures/* /data/profilepictures/*
/data/archive/* /data/archive/*
!/data/logs/ !/data/logs/

View file

@ -1,4 +1,4 @@
# Drinks Manager # Drinks Manager (Season 3)
Note: This software is tailored to my own needs. Note: This software is tailored to my own needs.
I probably won't accept feature requests, and don't recommend you I probably won't accept feature requests, and don't recommend you

View file

@ -3,7 +3,6 @@
from django.conf import settings from django.conf import settings
from django.db import connection from django.db import connection
from django.utils.translation import gettext from django.utils.translation import gettext
from calendar import day_name
COMBINE_ALPHABET = "abcdefghijklmnopqrstuvwxyz" COMBINE_ALPHABET = "abcdefghijklmnopqrstuvwxyz"
@ -16,6 +15,7 @@ def _db_select(sql_select:str):
result = cursor.fetchall() result = cursor.fetchall()
return result return result
def _combine_results(results:list) -> dict: def _combine_results(results:list) -> dict:
''' '''
e.g. e.g.
@ -80,7 +80,8 @@ def select_history(user, language_code="en") -> list:
result = [list(row) for row in result] result = [list(row) for row in result]
return result return result
def select_orders_per_month(user) -> dict:
def orders_per_month(user) -> list:
# number of orders per month (last 12 months) # number of orders per month (last 12 months)
result_user = _db_select(f""" result_user = _db_select(f"""
select select
@ -101,35 +102,32 @@ def select_orders_per_month(user) -> dict:
group by "month" group by "month"
order by "month" desc; order by "month" desc;
""") """)
return _combine_results([result_all, result_user]) return _combine_results([result_user, result_all])
def select_orders_per_weekday(user) -> list:
def orders_per_weekday(user) -> list:
# number of orders per weekday (all time) # number of orders per weekday (all time)
result = _db_select(f""" result_user = _db_select(f"""
with q_all as ( select
select to_char(datetime, 'Day') as "day",
extract(isodow from datetime) as "d", sum(amount) as "count"
sum(amount) as "c" from app_order
from app_order where user_id = {user.pk}
group by d group by "day"
), q_user as ( order by "count" desc;
select
extract(isodow from datetime) as "d",
sum(amount) as "c"
from app_order
where user_id = {user.pk}
group by d
)
select q_all.d as "day", q_all.c, q_user.c from q_all full join q_user on q_all.d = q_user.d
group by day, q_all.c, q_user.c
order by day asc;
""") """)
for i in range(len(result)): result_all = _db_select(f"""
day_, all_, user_ = result[i] select
result[i] = (day_name[int(day_)-1], all_, user_) to_char(datetime, 'Day') as "day",
return result sum(amount) as "count"
from app_order
group by "day"
order by "count" desc;
""")
return _combine_results([result_user, result_all])
def select_orders_per_drink(user) -> dict:
def orders_per_drink(user) -> list:
# number of orders per drink (all time) # number of orders per drink (all time)
result_user = _db_select(f""" result_user = _db_select(f"""
select select
@ -150,31 +148,4 @@ def select_orders_per_drink(user) -> dict:
group by d.product_name group by d.product_name
order by "data" desc; order by "data" desc;
""") """)
return _combine_results([result_all, result_user]) return _combine_results([result_user, result_all])
def select_order_sum_per_user_all_users() -> list:
# sum of all orders per user, for all users
result = _db_select(f"""
select
app_user.username as user,
sum(app_order.price_sum) as sum
from app_user
left outer join app_order on (app_user.id = app_order.user_id)
group by app_user.id
order by app_user asc;
""")
return result
def select_deposit_sum_per_user_all_users() -> list:
# sum of all orders per user, for all users
result = _db_select(f"""
select
app_user.username as user,
sum(rt.transaction_sum) as sum
from app_user
left outer join app_registertransaction rt on (app_user.id = rt.user_id)
where rt.is_user_deposit is true or rt.is_user_deposit is null
group by app_user.id
order by app_user asc;
""")
return result

Binary file not shown.

View file

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-11-01 19:29+0100\n" "POT-Creation-Date: 2023-04-14 23:37+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: Julian MĂĽller (ChaoticByte)\n" "Last-Translator: Julian MĂĽller (ChaoticByte)\n"
"Language: DE\n" "Language: DE\n"
@ -55,7 +55,7 @@ msgstr "Bestätigen"
msgid "Drinks - History" msgid "Drinks - History"
msgstr "Getränke - Verlauf" msgstr "Getränke - Verlauf"
#: app/templates/history.html:10 app/templates/userpanel.html:23 #: app/templates/history.html:10 app/templates/userpanel.html:25
msgid "History" msgid "History"
msgstr "Verlauf" msgstr "Verlauf"
@ -165,65 +165,49 @@ msgstr "Wähle deinen Account"
msgid "Drinks - Statistics" msgid "Drinks - Statistics"
msgstr "Getränke - Statistiken" msgstr "Getränke - Statistiken"
#: app/templates/statistics.html:10 app/templates/userpanel.html:24 #: app/templates/statistics.html:10 app/templates/userpanel.html:26
msgid "Statistics" msgid "Statistics"
msgstr "Statistiken" msgstr "Statistiken"
#: app/templates/statistics.html:13 #: app/templates/statistics.html:13
msgid "orders / drink" msgid "Orders per drink"
msgstr "Bestellungen / Getränk" msgstr "Bestellungen pro Getränk"
#: app/templates/statistics.html:16 #: app/templates/statistics.html:16
msgid "drink" msgid "drink"
msgstr "Getränk" msgstr "Getränk"
#: app/templates/statistics.html:17 app/templates/statistics.html:36 #: app/templates/statistics.html:17 app/templates/statistics.html:34
#: app/templates/statistics.html:53 #: app/templates/statistics.html:51
msgid "all"
msgstr "Alle"
#: app/templates/statistics.html:18 app/templates/statistics.html:37
#: app/templates/statistics.html:54
msgid "you" msgid "you"
msgstr "Du" msgstr "Du"
#: app/templates/statistics.html:32 #: app/templates/statistics.html:18 app/templates/statistics.html:35
msgid "orders / month" #: app/templates/statistics.html:52
msgstr "Bestellungen / Monat" msgid "all"
msgstr "Alle"
#: app/templates/statistics.html:35 #: app/templates/statistics.html:30
msgid "Orders per month (last 12 months)"
msgstr "Bestellungen pro Monat (letzte 12 Monate)"
#: app/templates/statistics.html:33
msgid "month" msgid "month"
msgstr "Monat" msgstr "Monat"
#: app/templates/statistics.html:49 #: app/templates/statistics.html:47
msgid "orders / weekday" msgid "Orders per weekday"
msgstr "Bestellungen / Wochentag" msgstr "Bestellungen pro Wochentag"
#: app/templates/statistics.html:52 #: app/templates/statistics.html:50
msgid "day" msgid "day"
msgstr "Tag" msgstr "Tag"
#: app/templates/statistics.html:69
msgid "order sum"
msgstr "Bestellungen"
#: app/templates/statistics.html:72 app/templates/statistics.html:89
msgid "user"
msgstr "Benutzer"
#: app/templates/statistics.html:73 app/templates/statistics.html:90
msgid "sum"
msgstr "Summe"
#: app/templates/statistics.html:86
msgid "deposit sum"
msgstr "Einzahlungen"
#: app/templates/supply.html:7 #: app/templates/supply.html:7
msgid "Drinks - Supply" msgid "Drinks - Supply"
msgstr "Getränke - Beschaffung" msgstr "Getränke - Beschaffung"
#: app/templates/supply.html:14 app/templates/userpanel.html:30 #: app/templates/supply.html:14 app/templates/userpanel.html:32
msgid "Supply" msgid "Supply"
msgstr "Beschaffung" msgstr "Beschaffung"
@ -244,6 +228,7 @@ msgid "You are not allowed to view this site."
msgstr "Dir fehlt die Berechtigung, diese Seite anzuzeigen." msgstr "Dir fehlt die Berechtigung, diese Seite anzuzeigen."
#: app/templates/transfer.html:6 #: app/templates/transfer.html:6
#| msgid "Drinks - Order"
msgid "Drinks - Transfer" msgid "Drinks - Transfer"
msgstr "Getränke - Geld senden" msgstr "Getränke - Geld senden"
@ -263,11 +248,11 @@ msgstr "Saldo"
msgid "Logout" msgid "Logout"
msgstr "Abmelden" msgstr "Abmelden"
#: app/templates/userpanel.html:28 #: app/templates/userpanel.html:30
msgid "Transfer" msgid "Transfer"
msgstr "Geld senden" msgstr "Geld senden"
#: app/templates/userpanel.html:32 #: app/templates/userpanel.html:34
msgid "Change Password" msgid "Change Password"
msgstr "Passwort ändern" msgstr "Passwort ändern"

View file

@ -40,7 +40,6 @@ class Drink(models.Model):
do_not_count = models.BooleanField(default=False) do_not_count = models.BooleanField(default=False)
def delete(self, *args, **kwargs): def delete(self, *args, **kwargs):
# we flag the field as deleted.
self.deleted = True self.deleted = True
super().save() super().save()
@ -108,9 +107,10 @@ class Order(models.Model):
price_sum = models.DecimalField(max_digits=6, decimal_places=2, default=0, editable=False) price_sum = models.DecimalField(max_digits=6, decimal_places=2, default=0, editable=False)
content_litres = models.DecimalField(max_digits=6, decimal_places=3, default=0, editable=False) content_litres = models.DecimalField(max_digits=6, decimal_places=3, default=0, editable=False)
# TODO: Add more comments on how and why the save & delete functions are implemented
# address this in a refactoring issue.
def save(self, *args, **kwargs): def save(self, *args, **kwargs):
# saving this may affect other fields
# so we reimplement the save function
drink = Drink.objects.get(pk=self.drink.pk) drink = Drink.objects.get(pk=self.drink.pk)
if self._state.adding and drink.available > 0: if self._state.adding and drink.available > 0:
if not drink.do_not_count: if not drink.do_not_count:
@ -126,7 +126,6 @@ class Order(models.Model):
raise ValidationError("This entry can't be changed.") raise ValidationError("This entry can't be changed.")
def delete(self, *args, **kwargs): def delete(self, *args, **kwargs):
# when deleting, we affect other fields as well.
self.user.balance += self.price_sum self.user.balance += self.price_sum
self.user.save() self.user.save()
drink = Drink.objects.get(pk=self.drink.pk) drink = Drink.objects.get(pk=self.drink.pk)

View file

@ -1,4 +1,4 @@
/* Fonts */ /* Font */
@font-face { @font-face {
font-family: "Inter"; font-family: "Inter";
@ -18,39 +18,26 @@
:root { :root {
--font-family: "Inter"; --font-family: "Inter";
--color: #fafafa; --color: #fafafa;
--color-disabled: #ffffff50; --color-error: #ff682c;
--color-error: #ff817c; --bg-page-color: #222222;
--bg-page: linear-gradient( --bg-color: #4e4e4e;
-10deg, --bg-hover-color: #636363;
#071c29 10%, --bg-color2: #383838;
#4a8897 --bg-hover-color2: #4a4a4a;
); --border-color: #808080;
--bg-color: #ffffff35;
--bg-color2: #ffffff25;
--bg-hover-color: #ffffff50;
--border-color: #ffffff50;
--bg-globalmessage: #161616; --bg-globalmessage: #161616;
--border-radius: .6rem; --border-radius: .5rem;
--element-padding: .6rem .8rem;
} }
/* General */ /* General */
body,
input,
select,
button, .button
{
font-family: var(--font-family);
}
body { body {
margin: 0; margin: 0;
padding: 0; padding: 0;
width: 100vw; width: 100vw;
min-height: 100vh; min-height: 100vh;
font-size: 17px; font-family: var(--font-family);
background: var(--bg-page); background: var(--bg-page-color);
color: var(--color); color: var(--color);
overflow-x: hidden; overflow-x: hidden;
} }
@ -60,7 +47,7 @@ a {
} }
h1 { h1 {
font-size: 28px; font-size: 1.8rem;
} }
h1, h2, h3, h4 { h1, h2, h3, h4 {
@ -78,36 +65,29 @@ input[type="number"]::-webkit-inner-spin-button {
display: none; display: none;
} }
input[type="text"], input[type="text"], input[type="password"], input[type="number"], select {
input[type="password"], padding: .6rem .8rem;
input[type="number"], text-align: center;
select { font-size: 1rem;
padding: var(--element-padding);
text-align: center !important;
font-size: 16px;
color: var(--color); color: var(--color);
border: none; border: none;
outline: none; outline: none;
border: 1px solid var(--border-color); border-bottom: 1px solid var(--border-color);
border-radius: var(--border-radius); border-radius: var(--border-radius);
background: var(--bg-color); background: var(--bg-color);
} font-family: "Inter";
input[type="text"]::placeholder,
input[type="password"]::placeholder,
input[type="number"]::placeholder,
select > option:disabled {
color: var(--color-disabled);
} }
select { select {
appearance: none; appearance: none;
-webkit-appearance: none; -webkit-appearance: none;
-moz-appearance: none; -moz-appearance: none;
height: 2.5rem;
background-image: url("/static/material-icons/arrow-drop-down.svg"); background-image: url("/static/material-icons/arrow-drop-down.svg");
background-repeat: no-repeat; background-repeat: no-repeat;
background-position: right; background-position: right;
background-size: 1.5rem; background-size: 1.5rem;
padding-right: 1.8rem;
} }
table { table {
@ -117,15 +97,20 @@ table {
border-radius: var(--border-radius); border-radius: var(--border-radius);
} }
tr > th, tr {
tr > td {
background: var(--bg-color); background: var(--bg-color);
} }
tr:nth-child(2n+2) > td { tr:nth-child(2n+2) {
background: var(--bg-color2); background: var(--bg-color2);
} }
/*
Rounded corners on table cells apparently don't work with
Firefox, so Firefox users won't have rounded corners
on tables. Can't fix that by myself.
*/
table tr:first-child th:first-child { table tr:first-child th:first-child {
border-top-left-radius: var(--border-radius); border-top-left-radius: var(--border-radius);
} }
@ -179,7 +164,11 @@ th {
flex-direction: row; flex-direction: row;
margin-top: 1rem; margin-top: 1rem;
width: 94%; width: 94%;
gap: 2rem; gap: 1rem;
}
.userinfo {
font-size: 1.05rem;
} }
.userinfo > span { .userinfo > span {
@ -234,7 +223,7 @@ main {
} }
.footer > div { .footer > div {
font-size: 16px; font-size: .95rem;
margin-top: .15rem; margin-top: .15rem;
margin-bottom: .15rem; margin-bottom: .15rem;
} }
@ -286,6 +275,15 @@ main {
gap: 1rem; gap: 1rem;
} }
.fill {
height: 100%;
width: 100%;
}
.fill-vertical {
height: 100%;
}
.buttons { .buttons {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
@ -298,26 +296,24 @@ main {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
font-family: var(--font-family);
text-decoration: none;
text-align: center !important;
background: var(--bg-color);
color: var(--color);
font-size: 1rem;
padding: .6rem .8rem;
outline: none; outline: none;
border: 1px solid var(--border-color); border: none;
border-bottom: 1px solid var(--border-color);
border-radius: var(--border-radius); border-radius: var(--border-radius);
cursor: pointer;
user-select: none;
box-sizing: content-box;
width: fit-content; width: fit-content;
} }
.button, button, .dropdownchoice { .button:hover, button:hover, .button:active, button:active {
padding: var(--element-padding);
font-size: 16px;
text-align: center !important;
text-decoration: none;
color: var(--color);
box-sizing: content-box;
cursor: pointer;
user-select: none;
background: var(--bg-color);
}
.button:hover, button:hover,
.button:active, button:active {
background: var(--bg-hover-color); background: var(--bg-hover-color);
} }
@ -325,55 +321,30 @@ main {
opacity: 40%; opacity: 40%;
} }
.formheading { .appform > .forminfo {
margin-bottom: 2rem; width: 100%;
}
.forminfo {
width: fit-content;
min-width: 16rem;
text-align: left; text-align: left;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
justify-content: space-between; justify-content: space-between;
gap: 2rem; gap: 2rem;
padding-bottom: .15rem;
border-bottom: 1px solid #ffffff20;
} }
.forminfo > span:last-child { .forminfo > span:last-child {
float: right; float: right;
} }
.appform, .appform > * {
max-width: 90vw;
}
.appform > .forminput { .appform > .forminput {
width: 100%; width: 100%;
flex-direction: row; flex-direction: row;
justify-content: space-between; justify-content: space-evenly;
align-items: center; align-items: center;
flex-wrap: wrap; flex-wrap: wrap;
gap: 1rem; gap: 1rem;
} }
.forminput > input, .forminput > select { .appform > .statusinfo {
width: 100% !important; margin-top: .5rem;
}
.forminput > .keyboard-input, #transfer-recipient {
/* the keyboard has a 5px padding */
margin-left: 5px !important;
margin-right: 5px !important;
}
.appform > .buttons {
margin-top: 1rem;
}
#statusinfo {
margin-top: 1rem;
} }
.dropdownmenu { .dropdownmenu {
@ -384,16 +355,6 @@ main {
border-radius: var(--border-radius); border-radius: var(--border-radius);
} }
#dropdownnope {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
margin: 0;
padding: 0;
}
.dropdownbutton { .dropdownbutton {
z-index: 190; z-index: 190;
} }
@ -404,69 +365,70 @@ main {
} }
.dropdownlist { .dropdownlist {
margin-top: 3rem;
position: absolute; position: absolute;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
border-radius: var(--border-radius);
box-shadow: 0 0 .5rem #00000025;
}
.dropdownlist, #dropdownnope {
visibility: hidden;
opacity: 0%;
pointer-events: none; pointer-events: none;
} border-radius: var(--border-radius) !important;
z-index: 200;
.dropdownvisible .dropdownlist, margin-top: 3.2rem;
.dropdownvisible #dropdownnope { opacity: 0%;
opacity: 100%; transition: opacity 100ms;
background: #00000020; box-shadow: 0 .25rem 1rem #00000090;
visibility: visible;
pointer-events: visible;
z-index: 100;
} }
.dropdownchoice { .dropdownchoice {
z-index: 200; border-radius: 0 !important;
margin: 0; margin: 0;
text-decoration: none; text-align: center;
justify-content: center;
background: var(--bg-color2) !important;
backdrop-filter: none !important;
width: initial; width: initial;
min-width: max-content;
border-bottom: 1px solid var(--border-color);
border-left: 1px solid var(--border-color);
border-right: 1px solid var(--border-color);
}
.dropdownchoice:first-child {
border-top: 1px solid var(--border-color);
border-top-left-radius: var(--border-radius);
border-top-right-radius: var(--border-radius);
}
.dropdownchoice:last-child {
border-bottom: 1px solid var(--border-color);
border-bottom-left-radius: var(--border-radius);
border-bottom-right-radius: var(--border-radius);
} }
.dropdownchoice:hover { .dropdownchoice:hover {
background: var(--bg-hover-color); background: var(--bg-hover-color2) !important;
}
.dropdownlist :first-child {
border-top-left-radius: var(--border-radius) !important;
border-top-right-radius: var(--border-radius) !important;
}
.dropdownlist :last-child {
border-bottom-left-radius: var(--border-radius) !important;
border-bottom-right-radius: var(--border-radius) !important;
}
.dropdownvisible .dropdownlist {
opacity: 100%;
visibility: visible;
pointer-events: visible;
} }
.customnumberinput { .customnumberinput {
height: 2.2rem; height: 2.5rem;
display: flex;
flex-direction: row;
align-items: center;
gap: .25rem;
} }
.customnumberinput button { .customnumberinput button {
width: 2.2rem !important; min-width: 2.5rem !important;
height: 2.2rem !important; width: 2.5rem !important;
padding: 0; padding: 0;
margin: 0; margin: 0;
height: 100%;
}
.customnumberinput-minus {
border-bottom-right-radius: 0;
border-top-right-radius: 0;
z-index: 10;
}
.customnumberinput-plus {
border-bottom-left-radius: 0;
border-top-left-radius: 0;
z-index: 10;
} }
.customnumberinput input[type="number"] { .customnumberinput input[type="number"] {
@ -475,13 +437,13 @@ main {
padding: 0; padding: 0;
margin: 0; margin: 0;
background: var(--bg-color2); background: var(--bg-color2);
border-radius: 0 !important;
-webkit-appearance: textfield; -webkit-appearance: textfield;
-moz-appearance: textfield; -moz-appearance: textfield;
appearance: textfield; appearance: textfield;
} }
.errortext { .errortext {
font-weight: bold;
color: var(--color-error); color: var(--color-error);
} }
@ -491,11 +453,6 @@ main {
/* Login */ /* Login */
.userlist-container {
flex-grow: 1;
padding-bottom: 10vh;
}
.userlist { .userlist {
width: 60%; width: 60%;
list-style: none; list-style: none;
@ -505,7 +462,8 @@ main {
} }
.userlist > li { .userlist > li {
padding: .1rem .6rem; margin-bottom: .5rem;
padding: 0 .5rem;
} }
.userlist > li > img { .userlist > li > img {
@ -518,7 +476,7 @@ main {
.userlist > li > div { .userlist > li > div {
flex-grow: 1; flex-grow: 1;
text-align: center; text-align: center;
padding: .7rem 1.1rem; padding: .8rem 1.1rem;
} }
.loginform { .loginform {
@ -530,18 +488,6 @@ main {
margin-top: 0; margin-top: 0;
} }
#passwordoverlay-container {
position: fixed;
width: 100vw;
height: 100vh;
top: 0;
right: 0;
background: var(--bg-page);
align-items: center;
padding-top: 10vh;
z-index: 200;
}
/* Drinks List */ /* Drinks List */
.drinks-list { .drinks-list {
@ -558,37 +504,7 @@ main {
.drinks-list > li > .button { .drinks-list > li > .button {
width: 100%; width: 100%;
justify-content: space-between; justify-content: space-between;
padding: .7rem 1.1rem; padding: .8rem 1.1rem;
}
/* Statistics */
.statistics-container {
display: flex;
flex-direction: row;
align-items: flex-start;
justify-content: center;
flex-wrap: wrap;
max-width: 90vw;
gap: 1rem;
}
.statistics-container > div {
height: 100%;
width: 16rem;
}
/* Blur */
@supports (backdrop-filter: blur()) {
.dropdownvisible #dropdownnope {
backdrop-filter: blur(16px);
}
#passwordoverlay-container {
background: #00000020;
backdrop-filter: blur(64px); /* fallback */
backdrop-filter: blur(128px);
}
} }
/* Responsive */ /* Responsive */
@ -611,10 +527,9 @@ main {
} }
} }
@media only screen and (max-width: 860px) { @media only screen and (max-width: 700px) {
.userpanel { .userpanel {
flex-direction: column; flex-direction: column;
gap: 1rem;
} }
.userlist { .userlist {
gap: 0.25rem; gap: 0.25rem;
@ -633,10 +548,7 @@ main {
} }
.dropdownlist { .dropdownlist {
width: 14rem; width: 14rem;
right: calc(50vw - 7rem); /* regard width */ right: calc(50vw - 7rem);
left: auto; left: auto;
} }
#keyboard {
display: none !important;
}
} }

View file

@ -6,7 +6,6 @@
max-width: 100%; max-width: 100%;
background: transparent; background: transparent;
font-family: "Inter"; font-family: "Inter";
font-size: 16px;
} }
.simple-keyboard.darkTheme .hg-button { .simple-keyboard.darkTheme .hg-button {
height: 50px; height: 50px;
@ -15,8 +14,8 @@
align-items: center; align-items: center;
background: var(--bg-color); background: var(--bg-color);
color: white; color: white;
border: 1px solid var(--border-color); border: none;
border-radius: var(--border-radius); border-bottom: 1px solid var(--border-color);
} }
.simple-keyboard.darkTheme .hg-button:active, .simple-keyboard.darkTheme .hg-button:active,
.simple-keyboard.darkTheme .hg-button:hover { .simple-keyboard.darkTheme .hg-button:hover {

View file

Before

Width:  |  Height:  |  Size: 43 KiB

After

Width:  |  Height:  |  Size: 43 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 41 KiB

After

Width:  |  Height:  |  Size: 41 KiB

Before After
Before After

View file

@ -6,6 +6,7 @@
let passwordOverlayElement; let passwordOverlayElement;
let pwOverlayCancelButton; let pwOverlayCancelButton;
let userlistButtons; let userlistButtons;
let pinpadButtons;
let userlistContainerElement; let userlistContainerElement;
// Add event listeners after DOM Content loaded // Add event listeners after DOM Content loaded
document.addEventListener("DOMContentLoaded", () => { document.addEventListener("DOMContentLoaded", () => {
@ -35,14 +36,9 @@
function show_password_overlay() { function show_password_overlay() {
window.scrollTo(0, 0); window.scrollTo(0, 0);
passwordOverlayElement.classList.remove("nodisplay"); passwordOverlayElement.classList.remove("nodisplay");
passwordInputElement.focus()
} }
function hide_password_overlay() { function hide_password_overlay() {
passwordOverlayElement.classList.add("nodisplay"); passwordOverlayElement.classList.add("nodisplay");
passwordInputElement.value = ""; passwordInputElement.value = "";
// Dispatch an Input Event to the input element to trigger the on-
// screen keyboard to update its buffer. This fixes a security
// issue on the login page.
passwordInputElement.dispatchEvent(new Event("input", {bubbles: true}));
} }
})(); })();

14
app/static/js/main.js Normal file
View file

@ -0,0 +1,14 @@
document.addEventListener("DOMContentLoaded", () => {
let dropdownmenuElement = document.getElementById("dropdownmenu");
let dropdownmenuButtonElement = document.getElementById("dropdownmenu-button");
if (dropdownmenuButtonElement != null) {
dropdownmenuButtonElement.addEventListener("click", () => {
if (dropdownmenuElement.classList.contains("dropdownvisible")) {
dropdownmenuElement.classList.remove("dropdownvisible");
}
else {
dropdownmenuElement.classList.add("dropdownvisible");
}
})
}
});

View file

@ -38,8 +38,7 @@
"1 2 3", "1 2 3",
"4 5 6", "4 5 6",
"7 8 9", "7 8 9",
"0 . ,", "{bksp} . ,"
"{bksp}"
] ]
} }
// Check if on smartphone // Check if on smartphone

View file

Before

Width:  |  Height:  |  Size: 145 B

After

Width:  |  Height:  |  Size: 145 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 240 B

After

Width:  |  Height:  |  Size: 240 B

Before After
Before After

View file

@ -25,7 +25,7 @@
<div class="flex flex-center"> <div class="flex flex-center">
{% translate "An error occured. Please log out and log in again." %} {% translate "An error occured. Please log out and log in again." %}
<br> <br>
<a class="button" href="/accounts/logout">log out</a> <a href="/accounts/logout">log out</a>
</div> </div>
{% endif %} {% endif %}
</main> </main>

View file

@ -8,16 +8,20 @@
{% block headAdditional %} {% block headAdditional %}
<link rel="stylesheet" href="/static/css/simple-keyboard.css"> <link rel="stylesheet" href="/static/css/simple-keyboard.css">
<link rel="stylesheet" href="/static/css/simple-keyboard_custom.css"> <link rel="stylesheet" href="/static/css/simple-keyboard_dark.css">
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<h1 class="formheading">{% translate "Deposit" %}</h1>
<form id="customform" class="flex flex-column flex-center appform gap-1rem" action="/api/deposit"> <form id="customform" class="flex flex-column flex-center appform gap-1rem" action="/api/deposit">
{% csrf_token %} {% csrf_token %}
<h1 class="formheading">{% translate "Deposit" %}</h1>
<div class="flex forminput"> <div class="flex forminput">
<input type="number" name="depositamount" class="keyboard-input depositamount" max="9999.99" min="1.00" step="0.01" placeholder="{% translate 'Amount' %} ({{ currency_suffix }})" autofocus required> <span>{% translate "Amount" %} {{ currency_suffix }}:</span>
<span>
<input type="number" name="depositamount" class="keyboard-input" max="9999.99" min="1.00" step="0.01" autofocus required>
</span>
</div> </div>
<div id="statusinfo"></div>
<!-- Virtual Keyboard --> <!-- Virtual Keyboard -->
<div id="keyboard" class="simple-keyboard" data-layout="numeric"></div> <div id="keyboard" class="simple-keyboard" data-layout="numeric"></div>
<script src="/static/js/simple-keyboard.js"></script> <script src="/static/js/simple-keyboard.js"></script>
@ -27,7 +31,6 @@
<input type="submit" id="submitbtn" class="button" value='{% translate "confirm" %}'> <input type="submit" id="submitbtn" class="button" value='{% translate "confirm" %}'>
</div> </div>
</form> </form>
<div id="statusinfo"></div>
<script src="/static/js/custom_form.js"></script> <script src="/static/js/custom_form.js"></script>
<script src="/static/js/autoreload.js"></script> <script src="/static/js/autoreload.js"></script>
{% endblock %} {% endblock %}

View file

@ -2,6 +2,6 @@
<footer class="footer-container"> <footer class="footer-container">
<div class="flex flex-row flex-center flex-wrap footer"> <div class="flex flex-row flex-center flex-wrap footer">
<div>Version {{ app_version }}</div> <div>Version {{ app_version }}</div>
<div>Copyright (C) 2021-2025, Julian MĂĽller (ChaoticByte)</div> <div>Copyright (C) 2021, Julian MĂĽller (ChaoticByte)</div>
</div> </div>
</footer> </footer>

View file

@ -11,31 +11,31 @@
<div class="flex flex-column flex-center"> <div class="flex flex-column flex-center">
{% if drink and drink.available > 0 and not drink.deleted %} {% if drink and drink.available > 0 and not drink.deleted %}
{% if user.balance > 0 or user.allow_order_with_negative_balance %} {% if user.balance > 0 or user.allow_order_with_negative_balance %}
<h1 class="formheading">{% translate "Order" %}</h1>
<form id="orderform" class="flex flex-column flex-center appform gap-1rem"> <form id="orderform" class="flex flex-column flex-center appform gap-1rem">
{% csrf_token %} {% csrf_token %}
<h1 class="formheading">{% translate "Order" %}</h1>
<div class="forminfo"> <div class="forminfo">
<span>{% translate "Drink" %}</span> <span>{% translate "Drink" %}:</span>
<span>{{ drink.product_name }}</span> <span>{{ drink.product_name }}</span>
</div> </div>
<div class="forminfo"> <div class="forminfo">
<span>{% translate "Price per Item" %} ({{ currency_suffix }})</span> <span>{% translate "Price per Item" %} ({{ currency_suffix }}):</span>
<span id="priceperdrink" data-drink-price="{% localize off %}{{ drink.price }}{% endlocalize %}"> <span id="priceperdrink" data-drink-price="{% localize off %}{{ drink.price }}{% endlocalize %}">
{{ drink.price }} {{ drink.price }}
</span> </span>
</div> </div>
{% if not drink.do_not_count %} {% if not drink.do_not_count %}
<div class="forminfo"> <div class="forminfo">
<span>{% translate "Available" %}</span> <span>{% translate "Available" %}:</span>
<span>{{ drink.available }}</span> <span>{{ drink.available }}</span>
</div> </div>
{% endif %} {% endif %}
<div class="forminfo"> <div class="forminfo">
<span>{% translate "Sum" %} ({{ currency_suffix }})</span> <span>{% translate "Sum" %} ({{ currency_suffix }}):</span>
<span id="ordercalculatedsum">{{ drink.price }}</span> <span id="ordercalculatedsum">{{ drink.price }}</span>
</div> </div>
<div class="flex forminput"> <div class="flex forminput">
<span>{% translate "Count" %}</span> <span>{% translate "Count" %}:</span>
<span class="flex flex-row customnumberinput"> <span class="flex flex-row customnumberinput">
<button type="button" class="customnumberinput-minus" id="numberofdrinks-btn-minus">-</button> <button type="button" class="customnumberinput-minus" id="numberofdrinks-btn-minus">-</button>
{% if drink.do_not_count %} {% if drink.do_not_count %}
@ -48,19 +48,19 @@
<button type="button" class="customnumberinput-plus" id="numberofdrinks-btn-plus">+</button> <button type="button" class="customnumberinput-plus" id="numberofdrinks-btn-plus">+</button>
</span> </span>
</div> </div>
<div id="statusinfo"></div>
<input type="hidden" name="drinkid" id="drinkid" value="{{ drink.id }}"> <input type="hidden" name="drinkid" id="drinkid" value="{{ drink.id }}">
<div class="buttons"> <div class="buttons">
<a href="/" class="button">{% translate "cancel" %}</a> <a href="/" class="button">{% translate "cancel" %}</a>
<input type="submit" id="ordersubmitbtn" class="button" value='{% translate "order" %}'> <input type="submit" id="ordersubmitbtn" class="button" value='{% translate "order" %}'>
</div> </div>
</form> </form>
<div id="statusinfo"></div>
<script src="/static/js/order.js"></script> <script src="/static/js/order.js"></script>
<script src="/static/js/custom_number_input.js"></script> <script src="/static/js/custom_number_input.js"></script>
{% else %} {% else %}
<div class="flex flex-center flex-column"> <div class="flex flex-center">
<p>{% translate "Your balance is too low to order a drink." %}</p> <p>{% translate "Your balance is too low to order a drink." %}</p>
<a href="/" class="button">{% translate "back" %}</a> <a href="/">{% translate "back" %}</a>
</div> </div>
{% endif %} {% endif %}
{% else %} {% else %}

View file

@ -10,7 +10,7 @@
{% block headAdditional %} {% block headAdditional %}
<link rel="stylesheet" href="/static/css/simple-keyboard.css"> <link rel="stylesheet" href="/static/css/simple-keyboard.css">
<link rel="stylesheet" href="/static/css/simple-keyboard_custom.css"> <link rel="stylesheet" href="/static/css/simple-keyboard_dark.css">
{% endblock %} {% endblock %}
{% block content %} {% block content %}
@ -19,7 +19,7 @@
{% endif %} {% endif %}
<div class="flex flex-column gap-1rem nodisplay" id="passwordoverlay-container"> <div class="flex flex-column gap-1rem nodisplay" id="passwordoverlay-container">
<div class="passwordoverlay"> <div class="passwordoverlay">
<h1 class="formheading">{% translate "Log in" %}</h1> <h1>{% translate "Log in" %}</h1>
<form method="post" action="{% url 'login' %}" class="flex flex-center loginform"> <form method="post" action="{% url 'login' %}" class="flex flex-center loginform">
{% csrf_token %} {% csrf_token %}
<input type="text" name="username" autofocus="" autocapitalize="none" autocomplete="username" maxlength="150" required="" id="id_username"> <input type="text" name="username" autofocus="" autocapitalize="none" autocomplete="username" maxlength="150" required="" id="id_username">
@ -36,7 +36,7 @@
<script src="/static/js/simple-keyboard.js"></script> <script src="/static/js/simple-keyboard.js"></script>
<script src="/static/js/simple-keyboard_configure.js"></script> <script src="/static/js/simple-keyboard_configure.js"></script>
</div> </div>
<div class="flex flex-column flex-center userlist-container"> <div class="flex flex-column flex-center">
<h1>{% translate "Choose your account" %}</h1> <h1>{% translate "Choose your account" %}</h1>
<ul class="flex flex-center flex-wrap userlist"> <ul class="flex flex-center flex-wrap userlist">
{% for user_ in user_list %} {% for user_ in user_list %}

View file

@ -8,96 +8,57 @@
{% block content %} {% block content %}
<h1>{% translate "Statistics" %}</h1> <h1>{% translate "Statistics" %}</h1>
<div class="statistics-container"> <div>
<div class="flex flex-column"> <div class="flex flex-column flex-center">
<h3>{% translate "orders / drink" %}</h3> <h3>{% translate "Orders per drink" %}</h3>
<table> <table>
<tr> <tr>
<th>{% translate "drink" %}</th> <th>{% translate "drink" %}</th>
<th>{% translate "all" %}</th>
<th>{% translate "you" %}</th> <th>{% translate "you" %}</th>
<th>{% translate "all" %}</th>
</tr> </tr>
{% for key, values in orders_per_drink.items %} {% for key, values in orders_per_drink.items %}
<tr> <tr>
<td>{{ key }}</td> <td>{{ key }}</td>
<td>{{ values.a|default:0 }}</td> <td>{{ values.a|default:"0" }}</td>
<td>{{ values.b|default:0 }}</td> <td>{{ values.b|default:"0" }}</td>
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>
</div> </div>
</div> <div class="flex flex-column flex-center">
<div class="statistics-container"> <h3>{% translate "Orders per month (last 12 months)" %}</h3>
<div class="flex flex-column">
<h3>{% translate "orders / month" %}</h3>
<table> <table>
<tr> <tr>
<th>{% translate "month" %}</th> <th>{% translate "month" %}</th>
<th>{% translate "all" %}</th>
<th>{% translate "you" %}</th> <th>{% translate "you" %}</th>
<th>{% translate "all" %}</th>
</tr> </tr>
{% for key, values in orders_per_month.items %} {% for key, values in orders_per_month.items %}
<tr> <tr>
<td>{{ key }}</td> <td>{{ key }}</td>
<td>{{ values.a|default:0 }}</td> <td>{{ values.a|default:"0" }}</td>
<td>{{ values.b|default:0 }}</td> <td>{{ values.b|default:"0" }}</td>
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>
</div> </div>
<div class="flex flex-column"> <div class="flex flex-column flex-center">
<h3>{% translate "orders / weekday" %}</h3> <h3>{% translate "Orders per weekday" %}</h3>
<table> <table>
<tr> <tr>
<th>{% translate "day" %}</th> <th>{% translate "day" %}</th>
<th>{% translate "all" %}</th>
<th>{% translate "you" %}</th> <th>{% translate "you" %}</th>
<th>{% translate "all" %}</th>
</tr> </tr>
{% for values in orders_per_weekday %} {% for key, values in orders_per_weekday.items %}
<tr> <tr>
<td>{{ values.0 }}</td> <td>{{ key }}</td>
<td>{{ values.1|default:0 }}</td> <td>{{ values.a|default:"0" }}</td>
<td>{{ values.2|default:0 }}</td> <td>{{ values.b|default:"0" }}</td>
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>
</div> </div>
</div>
<div class="statistics-container">
{% if user.is_superuser or perms.app.view_order %}
<div class="flex flex-column">
<h3>{% translate "order sum" %}</h3>
<table>
<tr>
<th>{% translate "user" %}</th>
<th>{% translate "sum" %}</th>
</tr>
{% for values in order_sum_per_user %}
<tr>
<td>{{ values.0 }}</td>
<td>{{ values.1|default:0.0 }} {{ currency_suffix }}</td>
</tr>
{% endfor %}
</table>
</div>
{% endif %}
{% if user.is_superuser or perms.app.view_registertransaction %}
<div class="flex flex-column">
<h3>{% translate "deposit sum" %}</h3>
<table>
<tr>
<th>{% translate "user" %}</th>
<th>{% translate "sum" %}</th>
</tr>
{% for values in deposit_sum_per_user %}
<tr>
<td>{{ values.0 }}</td>
<td>{{ values.1|default:0.0 }} {{ currency_suffix }}</td>
</tr>
{% endfor %}
</table>
</div>
{% endif %}
</div>
<script src="/static/js/autoreload.js"></script> <script src="/static/js/autoreload.js"></script>
{% endblock %} {% endblock %}

View file

@ -9,21 +9,27 @@
{% block content %} {% block content %}
{% if user.is_superuser or user.allowed_to_supply %} {% if user.is_superuser or user.allowed_to_supply %}
<h1 class="formheading">{% translate "Supply" %}</h1>
<form id="customform" class="flex flex-column flex-center appform gap-1rem" action="/api/supply"> <form id="customform" class="flex flex-column flex-center appform gap-1rem" action="/api/supply">
{% csrf_token %} {% csrf_token %}
<h1 class="formheading">{% translate "Supply" %}</h1>
<div class="flex forminput"> <div class="flex forminput">
<input type="text" name="supplydescription" placeholder="{% translate 'Description' %}" autofocus required> <span>{% translate "Description" %}:</span>
<span>
<input type="text" name="supplydescription" autofocus required>
</span>
</div> </div>
<div class="flex forminput"> <div class="flex forminput">
<input type="number" name="supplyprice" max="9999.99" min="1.00" step="0.01" placeholder="{% translate 'Price' %} ({{ currency_suffix }})" required> <span>{% translate "Price" %} ({{ currency_suffix }}):</span>
<span>
<input type="number" name="supplyprice" max="9999.99" min="1.00" step="0.01" required>
</span>
</div> </div>
<div id="statusinfo"></div>
<div class="buttons"> <div class="buttons">
<a href="/" class="button">{% translate "cancel" %}</a> <a href="/" class="button">{% translate "cancel" %}</a>
<input type="submit" id="submitbtn" class="button" value='{% translate "submit" %}'> <input type="submit" id="submitbtn" class="button" value='{% translate "submit" %}'>
</div> </div>
</form> </form>
<div id="statusinfo"></div>
<script src="/static/js/custom_form.js"></script> <script src="/static/js/custom_form.js"></script>
<script src="/static/js/custom_number_input.js"></script> <script src="/static/js/custom_number_input.js"></script>
{% else %} {% else %}

View file

@ -8,37 +8,44 @@
{% block headAdditional %} {% block headAdditional %}
<link rel="stylesheet" href="/static/css/simple-keyboard.css"> <link rel="stylesheet" href="/static/css/simple-keyboard.css">
<link rel="stylesheet" href="/static/css/simple-keyboard_custom.css"> <link rel="stylesheet" href="/static/css/simple-keyboard_dark.css">
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<h1 class="formheading">{% translate "Transfer Money" %}</h1>
<form id="customform" class="flex flex-column flex-center appform gap-1rem" action="/api/transfer"> <form id="customform" class="flex flex-column flex-center appform gap-1rem" action="/api/transfer">
{% csrf_token %} {% csrf_token %}
<h1 class="formheading">{% translate "Transfer Money" %}</h1>
<div class="flex forminput"> <div class="flex forminput">
<select name="recipientuser" id="transfer-recipient" required> <span>{% translate "Recipient" %}:</span>
<option value="" selected disabled>Recipient</option> <span>
{% for user_ in user_list %} <select name="recipientuser" required>
{% if user_.id != user.id %} <option></option>
<option value="{{user_.id}}"> {% for user_ in user_list %}
{% if user_.first_name %} {% if user_.id != user.id %}
{% if user_.last_name %} <option value="{{user_.id}}">
{{ user_.last_name }}, {% if user_.first_name %}
{% if user_.last_name %}
{{ user_.last_name }},
{% endif %}
{{ user_.first_name }}
{% elif user_.last_name %}
{{ user_.last_name }}
{% else %}
{{ user_.username }}
{% endif %} {% endif %}
{{ user_.first_name }} {% endif %}
{% elif user_.last_name %} </option>
{{ user_.last_name }} {% endfor %}
{% else %} </select>
{{ user_.username }} </span>
{% endif %}
{% endif %}
</option>
{% endfor %}
</select>
</div> </div>
<div class="flex forminput"> <div class="flex forminput">
<input type="number" name="transferamount" class="keyboard-input" max="{{ user.balance }}" min="0.01" step="0.01" placeholder="{% translate 'Amount' %} ({{ currency_suffix }})" autofocus required> <span>{% translate "Amount" %} {{ currency_suffix }}:</span>
<span>
<input type="number" name="transferamount" class="keyboard-input" max="{{ user.balance }}" min="0.01" step="0.01" autofocus required>
</span>
</div> </div>
<div id="statusinfo"></div>
<!-- Virtual Keyboard --> <!-- Virtual Keyboard -->
<div id="keyboard" class="simple-keyboard" data-layout="numeric"></div> <div id="keyboard" class="simple-keyboard" data-layout="numeric"></div>
<script src="/static/js/simple-keyboard.js"></script> <script src="/static/js/simple-keyboard.js"></script>
@ -48,7 +55,6 @@
<input type="submit" id="submitbtn" class="button" value='{% translate "confirm" %}'> <input type="submit" id="submitbtn" class="button" value='{% translate "confirm" %}'>
</div> </div>
</form> </form>
<div id="statusinfo"></div>
<script src="/static/js/custom_form.js"></script> <script src="/static/js/custom_form.js"></script>
<script src="/static/js/autoreload.js"></script> <script src="/static/js/autoreload.js"></script>
{% endblock %} {% endblock %}

View file

@ -18,20 +18,19 @@
<a class="button" href="/deposit">{% translate "Deposit" %}</a> <a class="button" href="/deposit">{% translate "Deposit" %}</a>
<a class="button" href="/accounts/logout">{% translate "Logout" %}</a> <a class="button" href="/accounts/logout">{% translate "Logout" %}</a>
<div class="dropdownmenu" id="dropdownmenu"> <div class="dropdownmenu" id="dropdownmenu">
<div id="dropdownnope"></div>
<button class="dropdownbutton" id="dropdownmenu-button"><img src="/static/material-icons/menu.svg"></button> <button class="dropdownbutton" id="dropdownmenu-button"><img src="/static/material-icons/menu.svg"></button>
<div class="dropdownlist"> <div class="dropdownlist">
<a class="dropdownchoice" href="/history">{% translate "History" %}</a> <a class="button dropdownchoice" href="/history">{% translate "History" %}</a>
<a class="dropdownchoice" href="/statistics">{% translate "Statistics" %}</a> <a class="button dropdownchoice" href="/statistics">{% translate "Statistics" %}</a>
{% if user.is_superuser or user.is_staff %} {% if user.is_superuser or user.is_staff %}
<a class="dropdownchoice" href="/admin/">Admin Panel</a> <a class="button dropdownchoice" href="/admin/">Admin Panel</a>
{% endif %} {% endif %}
<a class="dropdownchoice" href="/transfer/">{% translate "Transfer" %}</a> <a class="button dropdownchoice" href="/transfer/">{% translate "Transfer" %}</a>
{% if user.is_superuser or user.allowed_to_supply %} {% if user.is_superuser or user.allowed_to_supply %}
<a class="dropdownchoice" href="/supply/">{% translate "Supply" %}</a> <a class="button dropdownchoice" href="/supply/">{% translate "Supply" %}</a>
{% endif %} {% endif %}
<a class="dropdownchoice" href="/accounts/password_change/">{% translate "Change Password" %}</a> <a class="button dropdownchoice" href="/accounts/password_change/">{% translate "Change Password" %}</a>
</div> </div>
</div> </div>
</div> </div>
</div> </div>

View file

@ -80,17 +80,11 @@ def deposit(request):
@login_required @login_required
def statistics(request): def statistics(request):
user = request.user
context = { context = {
"orders_per_month": db_queries.select_orders_per_month(user), "orders_per_month": db_queries.orders_per_month(request.user),
"orders_per_weekday": db_queries.select_orders_per_weekday(user), "orders_per_weekday": db_queries.orders_per_weekday(request.user),
"orders_per_drink": db_queries.select_orders_per_drink(user), "orders_per_drink": db_queries.orders_per_drink(request.user),
} }
# Advanced statistics
if user.has_perm("app.view_order") or user.is_superuser:
context["order_sum_per_user"] = db_queries.select_order_sum_per_user_all_users()
if user.has_perm("app.view_registertransaction") or user.is_superuser:
context["deposit_sum_per_user"] = db_queries.select_deposit_sum_per_user_all_users()
return render(request, "statistics.html", context) return render(request, "statistics.html", context)
@login_required @login_required

View file

@ -9,8 +9,7 @@
{$CADDY_HOSTS} { {$CADDY_HOSTS} {
# the tls certificates # the tls certificates
# tls {$DATADIR}/tls/server.pem {$DATADIR}/tls/server-key.pem tls {$DATADIR}/tls/server.pem {$DATADIR}/tls/server-key.pem
tls internal
route { route {
# profile pictures # profile pictures
file_server /profilepictures/* { file_server /profilepictures/* {
@ -18,11 +17,7 @@
} }
# static files # static files
file_server /static/* { file_server /static/* {
root {$ROOTDIR} root {$DATADIR}/static/..
}
# django static files
file_server /django_static/* {
root {$DATADIR}/django_static/..
} }
# favicon # favicon
redir /favicon.ico /static/favicon.ico redir /favicon.ico /static/favicon.ico

View file

@ -149,8 +149,8 @@ LOCALE_PATHS = [
# Static files (CSS, JavaScript, Images) # Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.1/howto/static-files/ # https://docs.djangoproject.com/en/4.1/howto/static-files/
STATIC_URL = "django_static/" STATIC_URL = "static/"
STATIC_ROOT = BASE_DIR / "data" / "django_static" STATIC_ROOT = BASE_DIR / "data" / "static"
# Default primary key field type # Default primary key field type
# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field # https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field

View file

@ -1,4 +1,4 @@
Django~=4.2 Django~=4.1
psycopg2~=2.9 psycopg2~=2.9.5
uvicorn[standard]~=0.27 uvicorn~=0.20.0
PyYAML~=6.0 PyYAML~=6.0

View file

@ -14,7 +14,7 @@ from time import sleep
from yaml import safe_load from yaml import safe_load
banner = r""" ___ _ _ banner = """ ___ _ _
| \ _ _ (_) _ _ | |__ ___ ___ | \ _ _ (_) _ _ | |__ ___ ___
| |) || '_|| || ' \ | / /(_-< |___| | |) || '_|| || ' \ | / /(_-< |___|
|___/ |_| |_||_||_||_\_\/__/ |___/ |_| |_||_||_||_\_\/__/
@ -32,7 +32,6 @@ configuration_file = data_directory / "config.yml"
caddyfile = data_directory / "Caddyfile" caddyfile = data_directory / "Caddyfile"
logfile_caddy = logfile_directory / "caddy.log" logfile_caddy = logfile_directory / "caddy.log"
logfile_app = logfile_directory / "app.log" logfile_app = logfile_directory / "app.log"
logfile_sessioncleanup = logfile_directory / "session-cleanup.log"
class MonitoredSubprocess: class MonitoredSubprocess:
@ -131,7 +130,6 @@ if __name__ == "__main__":
["./venv/bin/python3", "./manage.py", "migrate", "--noinput"], env=os.environ).wait() ["./venv/bin/python3", "./manage.py", "migrate", "--noinput"], env=os.environ).wait()
# Caddy configuration via env # Caddy configuration via env
environment_caddy = os.environ environment_caddy = os.environ
environment_caddy["ROOTDIR"] = str(base_directory.absolute())
environment_caddy["DATADIR"] = str(data_directory.absolute()) environment_caddy["DATADIR"] = str(data_directory.absolute())
environment_caddy["CADDY_HOSTS"] = ", ".join(config["caddy"]["hosts"]) environment_caddy["CADDY_HOSTS"] = ", ".join(config["caddy"]["hosts"])
environment_caddy["HTTP_PORT"] = str(config["caddy"]["http_port"]) environment_caddy["HTTP_PORT"] = str(config["caddy"]["http_port"])
@ -185,6 +183,6 @@ if __name__ == "__main__":
MonitoredSubprocess( MonitoredSubprocess(
"Session Autocleaner", "Session Autocleaner",
["./scripts/_session-autocleaner.py", str(config["app"]["session_clear_interval"])], ["./scripts/_session-autocleaner.py", str(config["app"]["session_clear_interval"])],
logfile_sessioncleanup) logfile_app)
] ]
start_and_monitor(procs) start_and_monitor(procs)

View file

@ -11,6 +11,6 @@ chmod -c -R g-w,o-rwx .gitignore
export PYTHONPATH="$basedir" export PYTHONPATH="$basedir"
export DJANGO_SETTINGS_MODULE="project.settings" export DJANGO_SETTINGS_MODULE="project.settings"
export APP_VERSION="22" export APP_VERSION="16"
exec ./scripts/_bootstrap.py "$@" exec ./scripts/_bootstrap.py "$@"

View file

@ -1,21 +0,0 @@
document.addEventListener("DOMContentLoaded", () => {
let dropdownmenuElement = document.getElementById("dropdownmenu");
let dropdownmenuButtonElement = document.getElementById("dropdownmenu-button");
let dropdownmenuNopeElement = document.getElementById("dropdownnope");
function toggleDropDown() {
if (dropdownmenuElement.classList.contains("dropdownvisible")) {
dropdownmenuElement.classList.remove("dropdownvisible");
dropdownmenuNopeElement.classList.remove("dropdownvisible");
} else {
dropdownmenuElement.classList.add("dropdownvisible");
dropdownmenuNopeElement.classList.add("dropdownvisible");
}
}
if (dropdownmenuButtonElement != null) {
dropdownmenuButtonElement.addEventListener("click", toggleDropDown);
dropdownmenuNopeElement.addEventListener("click", () => {
dropdownmenuElement.classList.remove("dropdownvisible");
dropdownmenuNopeElement.classList.remove("dropdownvisible");
})
}
});