Merge branch 'process-delete' into 'master'

Process delete

See merge request medlabboulder/modpol!33
This commit is contained in:
2022-01-07 21:24:58 +00:00
12 changed files with 25 additions and 13 deletions

View File

@ -42,7 +42,7 @@ function add_child_org_consent:initiate(result)
self.initiator, self.initiator,
"Proposed child org: " .. input) "Proposed child org: " .. input)
-- initiate consent process -- initiate consent process
self.org:call_module( self:call_module(
"consent", "consent",
self.initiator, self.initiator,
{ {

View File

@ -128,7 +128,7 @@ end
--- propose_change --- propose_change
-- @field type "add" or "remove" -- @field type "add" or "remove"
function change_modules:propose_change(type, mod_text) function change_modules:propose_change(type, mod_text)
self.org:call_module( self:call_module(
"consent",self.initiator, "consent",self.initiator,
{ {
prompt = "Do you consent to "..type.. prompt = "Do you consent to "..type..

View File

@ -75,7 +75,7 @@ function change_modules:initiate(result)
self.data.summary = "\nRemove: ".. self.data.summary = "\nRemove: "..
table.concat(self.data.remove_modules,", ") table.concat(self.data.remove_modules,", ")
end end
self.org:call_module( self:call_module(
"consent", "consent",
self.initiator, self.initiator,
{ {

View File

@ -28,7 +28,7 @@ function create_token:initiate(result)
"Token name (alpha-numeric, no spaces):", "Token name (alpha-numeric, no spaces):",
function(input) function(input)
self.config.token_name = input self.config.token_name = input
self.org:call_module( self:call_module(
"tokenomics", "tokenomics",
self.initiator, self.initiator,
{ {

View File

@ -24,7 +24,7 @@ function join_org_consent:initiate(result)
self.org:delete_process(self.id) self.org:delete_process(self.id)
else else
self.data.result = result self.data.result = result
self.org:call_module( self:call_module(
"consent", "consent",
self.initiator, self.initiator,
{ {

View File

@ -38,7 +38,7 @@ function remove_child_consent:initiate(result)
children, children,
function(input) function(input)
self.data.child_to_remove = modpol.orgs.get_org(input) self.data.child_to_remove = modpol.orgs.get_org(input)
self.org:call_module( self:call_module(
"consent", "consent",
self.initiator, self.initiator,
{ {

View File

@ -32,7 +32,7 @@ function remove_member_consent:initiate(result)
self.org.members, self.org.members,
function(input) function(input)
self.data.member_to_remove = input self.data.member_to_remove = input
self.org:call_module( self:call_module(
"consent", "consent",
self.initiator, self.initiator,
{ {

View File

@ -24,7 +24,7 @@ function remove_org_consent:initiate(result)
self.org:delete_process(self.id) self.org:delete_process(self.id)
else else
self.data.result = result self.data.result = result
self.org:call_module( self:call_module(
"consent", "consent",
self.initiator, self.initiator,
{ {

View File

@ -64,7 +64,7 @@ function remove_process:initiate(result)
function(input) function(input)
if input == "Yes" then if input == "Yes" then
if process_mine then if process_mine then
self.org:delete_process(process_id) self.org:delete_process_tree(process_id)
modpol.interactions.message( modpol.interactions.message(
self.initiator, self.initiator,
"Removed process: "..process_choice) "Removed process: "..process_choice)
@ -73,7 +73,7 @@ function remove_process:initiate(result)
if result then result() end if result then result() end
self.org:delete_process(self.id) self.org:delete_process(self.id)
else else
self.org:call_module( self:call_module(
"consent", "consent",
self.initiator, self.initiator,
{ {
@ -86,7 +86,7 @@ function remove_process:initiate(result)
self.org.id, self.org.id,
"Removing process: ".. "Removing process: "..
process_choice) process_choice)
self.org:delete_process(process_id) self.org:delete_process_tree(process_id)
modpol.interactions.org_dashboard( modpol.interactions.org_dashboard(
self.initiator, self.org.id) self.initiator, self.org.id)
if result then result() end if result then result() end

View File

@ -45,7 +45,7 @@ function rename_org_consent:initiate(result)
"Proposed to change name of org " .. "Proposed to change name of org " ..
self.org.name .. " to " .. input) self.org.name .. " to " .. input)
-- initiate consent process -- initiate consent process
self.org:call_module( self:call_module(
"consent", "consent",
self.initiator, self.initiator,
{ {

View File

@ -47,7 +47,7 @@ function tokenomics:initiate(result)
self.org:delete_process(self.id) self.org:delete_process(self.id)
else else
if self.config.consent then if self.config.consent then
self.org:call_module( self:call_module(
"consent", "consent",
self.initiator, self.initiator,
{ {

View File

@ -48,6 +48,14 @@ function modpol.orgs:call_module(module_slug, initiator, config, result, parent_
return index return index
end end
function modpol.orgs:get_root_process(id)
local process = self.processes[id]
while (process.parent_id) do
process = self.processes[process.parent_id]
end
return process
end
function modpol.orgs:delete_process(id) function modpol.orgs:delete_process(id)
local process = self.processes[id] local process = self.processes[id]
if process and process ~= "deleted" then if process and process ~= "deleted" then
@ -66,6 +74,10 @@ function modpol.orgs:delete_process(id)
end end
end end
function modpol.orgs:delete_process_tree(id)
self:delete_process(self:get_root_process(id).id)
end
function modpol.orgs:add_pending_action(process_id, user, callback) function modpol.orgs:add_pending_action(process_id, user, callback)
self.pending[user] = self.pending[user] or {} self.pending[user] = self.pending[user] or {}
self.pending[user][process_id] = callback self.pending[user][process_id] = callback