mirror of
https://codeberg.org/metamuffin/abrechenbarkeit.git
synced 2024-12-27 15:44:34 +00:00
style negative user list; add embezzlement amount
This commit is contained in:
parent
80cf5a6ccd
commit
fb6eafaec0
3 changed files with 30 additions and 8 deletions
|
@ -540,7 +540,7 @@ local function r_users(show_special, filter_negative)
|
||||||
|
|
||||||
if not show_special then
|
if not show_special then
|
||||||
print(format([[
|
print(format([[
|
||||||
<form action="/" method="GET" id="user_creation">
|
<form class="section" action="/" method="GET" id="user_creation">
|
||||||
<h3>{+index.form.create_user}</h3>
|
<h3>{+index.form.create_user}</h3>
|
||||||
<label for="username">{+field.username}: </label>
|
<label for="username">{+field.username}: </label>
|
||||||
<input type="text" name="create_user" id="username" />
|
<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 show_user = function(user)
|
||||||
local is_spu = user.name:sub(1, 1) == "@"
|
local is_spu = user.name:sub(1, 1) == "@"
|
||||||
local filter_out = query.prefix ~= nil and user.name:sub(1, 1):lower() ~= query.prefix
|
local filter_out = query.prefix ~= nil and user.name:sub(1, 1):lower() ~= query.prefix
|
||||||
if (filter_negative ~= nil and user.balance < filter_negative)
|
if is_spu == show_special and
|
||||||
or (filter_negative == nil and is_spu == show_special and (not filter_out)) then
|
((filter_negative ~= nil and user.balance < filter_negative)
|
||||||
|
or (filter_negative == nil and (not filter_out))) then
|
||||||
print(format([[<li>
|
print(format([[<li>
|
||||||
<a href="/{username_url}">
|
<a href="/{username_url}">
|
||||||
<span class="name">{!username}</span>
|
<span class="name">{!username}</span>
|
||||||
|
@ -597,12 +598,32 @@ local function r_users(show_special, filter_negative)
|
||||||
}))
|
}))
|
||||||
end
|
end
|
||||||
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))
|
local inactive_cutoff = os.time() - (tonumber(config.inactive_cutoff) or (30 * 24 * 60 * 60))
|
||||||
for _, user in ipairs(get_active_users()) do
|
local embezzlement = 0
|
||||||
if filter_negative or user.time > inactive_cutoff then show_user(user) end
|
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
|
end
|
||||||
print("</ul>")
|
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">]]))
|
print(format([[<details><summary>{+users.inactive_list}</summary><ul class="userlist">]]))
|
||||||
for _, user in ipairs(users) do
|
for _, user in ipairs(users) do
|
||||||
if user.time <= inactive_cutoff then show_user(user) end
|
if user.time <= inactive_cutoff then show_user(user) end
|
||||||
|
|
|
@ -68,3 +68,4 @@ error.invalid_name=Name invalid
|
||||||
error.open_products=Failed to open products file
|
error.open_products=Failed to open products file
|
||||||
error.no_path=No path
|
error.no_path=No path
|
||||||
users.inactive_list=Inactive Users
|
users.inactive_list=Inactive Users
|
||||||
|
users.embezzlement=A total of {amount} are currently under embezzlement.
|
||||||
|
|
|
@ -97,11 +97,11 @@ nav> :last-child {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* landing page */
|
/* landing page */
|
||||||
form#user_creation {
|
.section {
|
||||||
background-color: var(--b2);
|
background-color: var(--b2);
|
||||||
padding: 1em;
|
padding: 1em;
|
||||||
margin-top: 2em;
|
margin-top: 2em;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
form#user_creation>h3 {
|
form#user_creation>h3 {
|
||||||
|
|
Loading…
Reference in a new issue