Adding and fixing basic modules for renaming, removing, and adding orgs

This commit is contained in:
Nathan Schneider
2021-12-19 16:00:26 -07:00
parent d4599e9bbe
commit 53d2a25f42
15 changed files with 371 additions and 130 deletions

View File

@@ -48,10 +48,10 @@ end
-- Function: modpol.interactions.org_dashboard
-- Params: user (string), org_name (string)
-- Params: user (string), org_string (string or id)
-- Output: Displays a menu of org-specific commands to the user
function modpol.interactions.org_dashboard(user, org_name)
local org = modpol.orgs.get_org(org_name)
function modpol.interactions.org_dashboard(user, org_string)
local org = modpol.orgs.get_org(org_string)
if not org then return nil end
-- identify parent
@@ -72,11 +72,13 @@ function modpol.interactions.org_dashboard(user, org_name)
-- list available modules
local org_modules = {}
for k,v in pairs(org.modules) do
table.insert(org_modules, v.slug)
if not v.hide then
table.insert(org_modules, v.slug)
end
end
-- list pending actions
local process_msg = #org.processes .. " total actions"
-- list pending
local process_msg = #org.processes .. " total processes"
if org.pending[user] then
process_msg = process_msg .. " (" .. #org.pending[user] .. " pending)"
else
@@ -84,14 +86,14 @@ function modpol.interactions.org_dashboard(user, org_name)
end
-- set up output
print("Org: " .. org_name)
print("Org: " .. org.name)
print("Parent: " .. parent)
print("Members: " .. table.concat(org.members, ", "))
print("Children: " .. table.concat(children, ", "))
print("Modules: " .. table.concat(org_modules, ", "))
print("Actions: " .. process_msg)
print("Pending: " .. process_msg)
print()
print("Commands: (M)odules, (A)ctions")
print("Commands: (M)odules, (P)ending")
local sel = io.read()
print()
@@ -114,7 +116,7 @@ function modpol.interactions.org_dashboard(user, org_name)
elseif sel == 'a' or sel == 'A' then
local processes = {}
print("All processes: (* indicates pending action)")
print("All processes: (* indicates pending)")
for k,v in ipairs(org.processes) do
local active = ''
if org.pending[user] then
@@ -135,7 +137,7 @@ function modpol.interactions.org_dashboard(user, org_name)
end
else
print("Command not found")
modpol.interactions.org_dashboard(user, org_name)
modpol.interactions.org_dashboard(user, org.name)
end
end