From d04dbb8a4f28b5fbfd221d47fbdb52fc9f9b9c80 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Sat, 9 Nov 2024 00:35:52 +0100 Subject: [PATCH] add spus view --- abrechenbarkeit.lua | 45 ++++++++++++++++++++++++++++++++------------- locale/en.ini | 4 ++++ style.css | 14 +++++++++----- 3 files changed, 45 insertions(+), 18 deletions(-) diff --git a/abrechenbarkeit.lua b/abrechenbarkeit.lua index 26fcfac..fe3c781 100755 --- a/abrechenbarkeit.lua +++ b/abrechenbarkeit.lua @@ -200,8 +200,10 @@ local function respond(status, title, body) {+appname} - {+log} + {+users} + {+spus} {+products} + {+log} {+about} ]], { @@ -211,7 +213,13 @@ local function respond(status, title, body) script = script, head_extra = config.head_extra or "" })) + if config.header ~= nil then + print(config.header) + end body() + if config.footer ~= nil then + print(config.footer) + end print("") end @@ -344,7 +352,7 @@ local function r_transaction_post() return error_box("unknown product") end end - user_src = user_src or "@global" + user_src = user_src or "@Potential" if amount == nil then return error_box("amount invalid") end @@ -383,12 +391,17 @@ local function r_user(username) notif = r_transaction_post() end return respond(200, string.format("Abrechenbarheit: %s", username), function() - print(format("

{username}

", { username = username })) + local is_special = username:sub(1, 1) == "@" + local username_display = username:gsub("@", "") + print(format(is_special and "

{!username}

" or "

{!username}

", { username = username_display })) local balance = balances()[username] local last_txn = last_txns()[username] local new_user = balance == nil balance = balance or 0 if notif then print(notif) end + if is_special then + print(format([[

{+user.special}

]])) + end if new_user then print(format([[

{+user.lazy_creation}

]])) else @@ -404,7 +417,7 @@ local function r_user(username) for _, type in ipairs({ 1, -1 }) do for _, amount in ipairs({ 50, 100, 150, 200, 500, 1000 }) do local a = amount * type - print(format([[
+ print(format([[ @@ -413,13 +426,14 @@ local function r_user(username) username = username, a_raw = a, amount = format_amount(a), - sign = a < 0 and "neg" or "pos" + sign = a < 0 and "neg" or "pos", + disable_class = is_special and "disabled" or "" })) end end print("") print(format([[ - +

{+user.form.transaction}

@@ -428,7 +442,7 @@ local function r_user(username)
-
+

{+user.form.buy}

@@ -438,7 +452,7 @@ local function r_user(username)
-
+

{+user.form.restock}

@@ -449,7 +463,7 @@ local function r_user(username)
- ]], { username = username })) + ]], { username = username, disable_class = is_special and "disabled" or "" })) print("") end) end @@ -520,7 +534,7 @@ local function r_log(filter) end) end -local function r_index() +local function r_users(show_special) return respond(200, "Abrechenbarkeit", function() print(format([[
@@ -533,7 +547,8 @@ local function r_index() print([[
]]) -- for printing print([[