Merge branch 'process-delete' into 'master'

Process delete

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -48,6 +48,14 @@ function modpol.orgs:call_module(module_slug, initiator, config, result, parent_
return index
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)
local process = self.processes[id]
if process and process ~= "deleted" then
@ -66,6 +74,10 @@ function modpol.orgs:delete_process(id)
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)
self.pending[user] = self.pending[user] or {}
self.pending[user][process_id] = callback