|
@@ -1,29 +1,62 @@
|
|
--- @module add_child_org
|
|
--- @module add_child_org
|
|
-- Adds a child org
|
|
-- Adds a child org
|
|
|
|
+-- Depends on `consent`
|
|
|
|
|
|
local add_child_org = {
|
|
local add_child_org = {
|
|
name = "Add child org",
|
|
name = "Add child org",
|
|
slug = "add_child_org",
|
|
slug = "add_child_org",
|
|
- desc = "Create a child org within the current one"
|
|
|
|
|
|
+ desc = "Create a child org within the current one with consent"
|
|
}
|
|
}
|
|
add_child_org.data = {
|
|
add_child_org.data = {
|
|
|
|
+ child_name = ""
|
|
}
|
|
}
|
|
add_child_org.config = {
|
|
add_child_org.config = {
|
|
}
|
|
}
|
|
|
|
|
|
-- @function initiate
|
|
-- @function initiate
|
|
-function add_child_org:initiate(result)
|
|
|
|
|
|
+function add_child_org:initiate(config, result)
|
|
|
|
+ self.org:add_pending_action(
|
|
|
|
+ self.id, self.initiator,
|
|
|
|
+ "name_child_org")
|
|
|
|
+end
|
|
|
|
+
|
|
|
|
+function add_child_org:name_child_org()
|
|
modpol.interactions.text_query(
|
|
modpol.interactions.text_query(
|
|
self.initiator,"Child org name: ",
|
|
self.initiator,"Child org name: ",
|
|
function(input)
|
|
function(input)
|
|
- self.org:add_org(input, self.initiator)
|
|
|
|
- modpol.interactions.message_org(
|
|
|
|
- self.initiator,
|
|
|
|
- self.org.id,
|
|
|
|
- "Child org created: "..input)
|
|
|
|
- modpol.interactions.dashboard(self.initiator)
|
|
|
|
- end)
|
|
|
|
|
|
+ if input == "" then
|
|
|
|
+ modpol.interactions.message(
|
|
|
|
+ self.initiator,
|
|
|
|
+ "No name entered for child org")
|
|
|
|
+ self.org:wipe_pending_actions(self.id)
|
|
|
|
+ return end
|
|
|
|
+ self.data.child_name = input
|
|
|
|
+ modpol.interactions.message(
|
|
|
|
+ self.initiator,
|
|
|
|
+ "Proposed child org: " .. input)
|
|
|
|
+ self.org:wipe_pending_actions(self.id)
|
|
|
|
+ self:propose_child_org()
|
|
|
|
+ end
|
|
|
|
+ )
|
|
end
|
|
end
|
|
|
|
|
|
|
|
+function add_child_org:propose_child_org()
|
|
|
|
+ self.org:call_module(
|
|
|
|
+ "consent",
|
|
|
|
+ self.initiator,
|
|
|
|
+ {
|
|
|
|
+ prompt = "Create child org " .. self.data.child_name .. "?",
|
|
|
|
+ votes_required = #self.org.members
|
|
|
|
+ },
|
|
|
|
+ function()
|
|
|
|
+ self.org:add_org(self.data.child_name, self.initiator)
|
|
|
|
+ modpol.interactions.message_org(
|
|
|
|
+ self.initiator,
|
|
|
|
+ self.org.id,
|
|
|
|
+ "Child org created: "..self.data.child_name)
|
|
|
|
+ end
|
|
|
|
+ )
|
|
|
|
+end
|
|
|
|
+
|
|
--- (Required) Add to module table
|
|
--- (Required) Add to module table
|
|
modpol.modules.add_child_org = add_child_org
|
|
modpol.modules.add_child_org = add_child_org
|