|
@@ -1,26 +1,26 @@
|
|
|
---- Remove child (consent).
|
|
|
--- A simple module that calls a consent process on an org to remove its child.
|
|
|
--- Depends on the Consent module.
|
|
|
--- @module remove_child_consent
|
|
|
+--- Remove child org
|
|
|
+-- A simple module that calls a process on an org to remove its child.
|
|
|
+-- @module remove_child_org
|
|
|
|
|
|
-local remove_child_consent = {
|
|
|
- name = "Remove child (consent)",
|
|
|
- slug = "remove_child_consent",
|
|
|
- desc = "Removes a child org if all members of this org consent."
|
|
|
+local remove_child_org = {
|
|
|
+ name = "Remove child org",
|
|
|
+ slug = "remove_child_org",
|
|
|
+ desc = "Removes a child org."
|
|
|
}
|
|
|
|
|
|
-remove_child_consent.data = {
|
|
|
+remove_child_org.data = {
|
|
|
result = nil,
|
|
|
child_to_remove = nil
|
|
|
}
|
|
|
|
|
|
-remove_child_consent.config = {
|
|
|
+remove_child_org.config = {
|
|
|
+ approval_module = false
|
|
|
}
|
|
|
|
|
|
--- Removes a child org with consent
|
|
|
--- @function remove_child_consent:initiate
|
|
|
+-- @function remove_child_org:initiate
|
|
|
-- @param result Callback if this module is embedded in other modules
|
|
|
-function remove_child_consent:initiate(result)
|
|
|
+function remove_child_org:initiate(result)
|
|
|
local children = {}
|
|
|
for i,v in ipairs(self.org.children) do
|
|
|
local child = modpol.orgs.get_org(v)
|
|
@@ -43,11 +43,10 @@ function remove_child_consent:initiate(result)
|
|
|
function(input)
|
|
|
self.data.child_to_remove = modpol.orgs.get_org(input)
|
|
|
self:call_module(
|
|
|
- "consent",
|
|
|
+ self.config.approval_module,
|
|
|
self.initiator,
|
|
|
{
|
|
|
- prompt = "Remove child org "..input.."?",
|
|
|
- votes_required = #self.org.members
|
|
|
+ prompt = "Remove child org "..input.."?"
|
|
|
},
|
|
|
function()
|
|
|
self:complete()
|
|
@@ -59,19 +58,18 @@ function remove_child_consent:initiate(result)
|
|
|
end
|
|
|
|
|
|
--- Complete the remove process
|
|
|
--- @function remove_child_consent:complete
|
|
|
-function remove_child_consent:complete()
|
|
|
+-- @function remove_child_org:complete
|
|
|
+function remove_child_org:complete()
|
|
|
modpol.interactions.message_org(
|
|
|
self.initiator, self.data.child_to_remove.id,
|
|
|
- "Removing org " .. self.data.child_to_remove.name ..
|
|
|
- " by parent org consent")
|
|
|
+ "Removing this org: " .. self.data.child_to_remove.name)
|
|
|
modpol.interactions.message_org(
|
|
|
self.initiator, self.org.id,
|
|
|
- "Consent reached: removing org " ..
|
|
|
+ "Removing child org of " .. self.org.name .. ": " ..
|
|
|
self.data.child_to_remove.name)
|
|
|
self.data.child_to_remove:delete()
|
|
|
if self.data.result then self.data.result() end
|
|
|
self.org:delete_process(self.id)
|
|
|
end
|
|
|
|
|
|
-modpol.modules.remove_child_consent = remove_child_consent
|
|
|
+modpol.modules.remove_child_org = remove_child_org
|