diff options
author | Riley L. <riley@e926.de> | 2024-11-20 22:34:56 +0100 |
---|---|---|
committer | Riley L. <riley@e926.de> | 2024-11-20 22:34:56 +0100 |
commit | fb6eafaec0581b4754ae99a7a719e3e9b40a6106 (patch) | |
tree | f1fcb7a346d799dc05d27785ea0317d12d768774 /abrechenbarkeit.lua | |
parent | 80cf5a6ccd6a800bcf9294ec2f8a90aadf800f4e (diff) | |
download | abrechenbarkeit-fb6eafaec0581b4754ae99a7a719e3e9b40a6106.tar abrechenbarkeit-fb6eafaec0581b4754ae99a7a719e3e9b40a6106.tar.bz2 abrechenbarkeit-fb6eafaec0581b4754ae99a7a719e3e9b40a6106.tar.zst |
style negative user list; add embezzlement amount
Diffstat (limited to 'abrechenbarkeit.lua')
-rwxr-xr-x | abrechenbarkeit.lua | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/abrechenbarkeit.lua b/abrechenbarkeit.lua index b7ec392..41b4e8f 100755 --- a/abrechenbarkeit.lua +++ b/abrechenbarkeit.lua @@ -540,7 +540,7 @@ local function r_users(show_special, filter_negative) if not show_special then print(format([[ - <form action="/" method="GET" id="user_creation"> + <form class="section" action="/" method="GET" id="user_creation"> <h3>{+index.form.create_user}</h3> <label for="username">{+field.username}: </label> <input type="text" name="create_user" id="username" /> @@ -583,8 +583,9 @@ local function r_users(show_special, filter_negative) local show_user = function(user) local is_spu = user.name:sub(1, 1) == "@" local filter_out = query.prefix ~= nil and user.name:sub(1, 1):lower() ~= query.prefix - if (filter_negative ~= nil and user.balance < filter_negative) - or (filter_negative == nil and is_spu == show_special and (not filter_out)) then + if is_spu == show_special and + ((filter_negative ~= nil and user.balance < filter_negative) + or (filter_negative == nil and (not filter_out))) then print(format([[<li> <a href="/{username_url}"> <span class="name">{!username}</span> @@ -597,12 +598,32 @@ local function r_users(show_special, filter_negative) })) end end + + if filter_negative ~= nil then + table.sort(users, function(a, b) + return a.balance < b.balance + end) + end + local inactive_cutoff = os.time() - (tonumber(config.inactive_cutoff) or (30 * 24 * 60 * 60)) - for _, user in ipairs(get_active_users()) do - if filter_negative or user.time > inactive_cutoff then show_user(user) end + local embezzlement = 0 + for _, user in ipairs(users) do + if filter_negative or user.time > inactive_cutoff then + show_user(user) + + if user.name:sub(1,1) ~= "@" then + if user.balance < 0 then embezzlement = embezzlement - user.balance end + end + end end print("</ul>") - if filter_negative ~= nil then return end + if filter_negative ~= nil then + print(format([[<section class="section" style="margin-top: 0">{+users.embezzlement}</section>]], { + amount = format_amount(embezzlement) + })) + + return + end print(format([[<details><summary>{+users.inactive_list}</summary><ul class="userlist">]])) for _, user in ipairs(users) do if user.time <= inactive_cutoff then show_user(user) end |