Created no-consent add_child_org module and a bugfix

This commit is contained in:
Nathan Schneider
2022-01-27 13:32:12 -07:00
parent cdb8e44099
commit 509d2781f7
3 changed files with 68 additions and 1 deletions

View File

@ -0,0 +1,66 @@
--- Adds a child org.
-- @module add_child_org
local add_child_org = {
name = "Add child org",
slug = "add_child_org",
desc = "Create a child org in the current one"
}
add_child_org.data = {
child_name = "",
result = nil
}
add_child_org.config = {
}
--- Initiate consent for new child org
-- @function add_child_org:initiate(result)
-- @param result Callback if this module is embedded in other modules
function add_child_org:initiate(result)
modpol.interactions.text_query(
self.initiator,"Child org name: ",
function(input)
if input == "" then
modpol.interactions.message(
self.initiator,
"No name entered for child org")
modpol.interactions.org_dashboard(
self.initiator, self.org.name)
self.org:delete_process(self.id)
return
elseif modpol.orgs.get_org(input) then
modpol.interactions.message(
self.initiator,
"Org name already in use")
modpol.interactions.org_dashboard(
self.initiator, self.org.name)
self.org:delete_process(self.id)
if result then result() end
return
end
self.data.child_name = input
modpol.interactions.message(
self.initiator,
"Proposed child org: " .. input)
-- create the org
self:create_child_org()
modpol.interactions.org_dashboard(
self.initiator, self.org.name)
end
)
end
--- Create a new child orgg
-- @function add_child_org:create_child_org
function add_child_org:create_child_org()
self.org:add_org(self.data.child_name, self.initiator)
modpol.interactions.message_org(
self.initiator,
self.org.name,
"Created child org "
..self.data.child_name)
if self.data.result then self.data.result() end
self.org:delete_process(self.id)
end
modpol.modules.add_child_org = add_child_org