First shot at a generic approve() function for modules, testing on change_policy
This commit is contained in:
@ -9,11 +9,11 @@ local change_policy = {
|
||||
}
|
||||
|
||||
change_policy.data = {
|
||||
result = nil
|
||||
result = false
|
||||
}
|
||||
|
||||
change_policy.config = {
|
||||
approval = "none"
|
||||
approval_module = false
|
||||
}
|
||||
|
||||
--- Change modules initiate
|
||||
@ -23,8 +23,7 @@ function change_policy:initiate(result)
|
||||
-- prepare module options
|
||||
local available_modules = {}
|
||||
for k,org_mod in pairs(modpol.modules) do
|
||||
if not org_mod.hide and
|
||||
self.org.policies[k] then
|
||||
if self.org.policies[k] then
|
||||
available_modules[org_mod.slug] = modpol.util.copy_table(org_mod)
|
||||
end end
|
||||
local modules_list = {}
|
||||
@ -94,17 +93,23 @@ end
|
||||
-- @param policy (string) policy slug
|
||||
-- @param input (string) input content
|
||||
function change_policy:approve_change(module_slug, policy, input)
|
||||
-- NEED TO ADD APPROVAL CODE for consent, etc.
|
||||
modpol.interactions.message(
|
||||
self.initiator,
|
||||
"Updating " .. policy .. " policy on module " ..
|
||||
module_slug .. " with: " .. input)
|
||||
self.org.policies[module_slug][policy] = input
|
||||
modpol.interactions.org_dashboard(
|
||||
self.initiator, self.org.id)
|
||||
if self.data.result then self.data.result() end
|
||||
self.org:delete_process(self.id)
|
||||
return
|
||||
self.org:approve(
|
||||
approval_module,
|
||||
self,
|
||||
{prompt = "Update " .. policy .. " policy on module " ..
|
||||
module_slug .. " with: " .. input .. " ?"},
|
||||
function()
|
||||
modpol.interactions.message(
|
||||
self.initiator,
|
||||
"Updating " .. policy .. " policy on module " ..
|
||||
module_slug .. " with: " .. input)
|
||||
self.org.policies[module_slug][policy] = input
|
||||
modpol.interactions.org_dashboard(
|
||||
self.initiator, self.org.id)
|
||||
if self.data.result then self.data.result() end
|
||||
self.org:delete_process(self.id)
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
modpol.modules.change_policy = change_policy
|
||||
|
Reference in New Issue
Block a user