First shot at a generic approve() function for modules, testing on change_policy
This commit is contained in:
@ -64,6 +64,36 @@ function modpol.orgs:call_module(module_slug, initiator, config, result, parent_
|
||||
return index
|
||||
end
|
||||
|
||||
--- Generic approval check for modules, able to call other modules
|
||||
-- @function modpol.orgs.approve
|
||||
-- @param approval_module Slug of module used to approve, or nil
|
||||
-- @param process The parent process of which this is part
|
||||
-- @param config Config for module
|
||||
-- @param result Function for what gets done if approved
|
||||
function modpol.orgs:approve(approval_module, process, config, result)
|
||||
if not approval_module then -- if nil then simply approve
|
||||
result()
|
||||
return
|
||||
elseif not modpol.modules[approval_module] then
|
||||
modpol.interactions.message(
|
||||
process.initiator,
|
||||
"Approval process failed: module " .. approval_module
|
||||
.. " does not exist.")
|
||||
modpol.interactions.org_dashboard(
|
||||
process.initiator, process.org.id)
|
||||
process.org:delete_process(process.id)
|
||||
return
|
||||
else
|
||||
-- call module
|
||||
modpol.orgs:call_module(
|
||||
approval_module,
|
||||
process.initiator,
|
||||
config,
|
||||
result, process.id)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--- Get the root process of the given id
|
||||
-- @function modpol.orgs.get_root_process
|
||||
-- @param id
|
||||
@ -76,7 +106,7 @@ function modpol.orgs:get_root_process(id)
|
||||
return process
|
||||
end
|
||||
|
||||
--- Delete the process given id
|
||||
--- Delete the process given id, return to dashboard
|
||||
-- @function modpol.orgs.delete_process
|
||||
-- @param id
|
||||
function modpol.orgs:delete_process(id)
|
||||
@ -97,6 +127,7 @@ function modpol.orgs:delete_process(id)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--- Delete process tree by id
|
||||
-- @function modpol.orgs:delete_process_tree
|
||||
-- @param id Id of process tree
|
||||
|
Reference in New Issue
Block a user