1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- --- @module add_child_org
- -- Adds a child org
- -- Depends on `consent`
- local add_child_org = {
- name = "Add child org",
- slug = "add_child_org",
- desc = "Create a child org within the current one with consent"
- }
- add_child_org.data = {
- child_name = ""
- }
- add_child_org.config = {
- }
- -- @function initiate
- 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(
- self.initiator,"Child org name: ",
- function(input)
- 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
- 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
- modpol.modules.add_child_org = add_child_org
|