Major improvements on policy configuration
- Bugfixes on change_policy - Replaced _consent modules with configurable modules
This commit is contained in:
@ -1,32 +1,57 @@
|
||||
--- A simple module that removes an org.
|
||||
--- Remove org
|
||||
-- Removes the current org
|
||||
-- @module remove_org
|
||||
|
||||
remove_org = {
|
||||
local remove_org = {
|
||||
name = "Remove this org",
|
||||
slug = "remove_org",
|
||||
desc = "Eliminates the org and all child orgs."
|
||||
desc = "Removes this org."
|
||||
}
|
||||
|
||||
remove_org.config = {}
|
||||
remove_org.data = {}
|
||||
remove_org.data = {
|
||||
result = nil
|
||||
}
|
||||
|
||||
--- Removes org
|
||||
remove_org.config = {
|
||||
approval_module = false
|
||||
}
|
||||
|
||||
--- Remove org if all members consent
|
||||
-- @function remove_org:initiate
|
||||
-- @param result Callback if this module is embedded in other modules
|
||||
function remove_org:initiate(result)
|
||||
if self.org == modpol.instance then
|
||||
modpol.interactions.message(
|
||||
self.initiator,
|
||||
"Cannot remove the root org")
|
||||
modpol.interactions.message(
|
||||
self.initiator,
|
||||
"Cannot remove root org")
|
||||
if result then result() end
|
||||
self.org:delete_process(self.id)
|
||||
else
|
||||
modpol.interactions.message_org(
|
||||
self.initiator,self.org.id,
|
||||
"Removing org: "..self.org.name)
|
||||
self.org:delete()
|
||||
modpol.interactions.dashboard(self.initiator)
|
||||
-- call result function
|
||||
self.data.result = result
|
||||
self:call_module(
|
||||
self.config.approval_module,
|
||||
self.initiator,
|
||||
{
|
||||
prompt = "Remove org " .. self.org.name .. "?"
|
||||
},
|
||||
function()
|
||||
self:complete()
|
||||
end
|
||||
)
|
||||
modpol.interactions.org_dashboard(
|
||||
self.initiator, modpol.orgs.get_org(self.org.parent).name)
|
||||
end
|
||||
if result then result() end
|
||||
end
|
||||
|
||||
--- Complete after approval
|
||||
-- @function remove_org:complete
|
||||
function remove_org:complete()
|
||||
modpol.interactions.message_org(
|
||||
self.initiator, self.org.id,
|
||||
"Removing org " .. self.org.name)
|
||||
if self.data.result then self.data.result() end
|
||||
self.org:delete_process(self.id)
|
||||
self.org:delete()
|
||||
end
|
||||
|
||||
modpol.modules.remove_org = remove_org
|
||||
|
Reference in New Issue
Block a user