Browse Source

Merge branch 'process-delete' into 'master'

Process delete

See merge request medlabboulder/modpol!33
Nathan Schneider 2 years ago
parent
commit
ba65b471b3

+ 1 - 1
modpol_core/modules/add_child_org_consent.lua

@@ -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, 
             {

+ 1 - 1
modpol_core/modules/change_modules-dropdown.lua

@@ -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..

+ 1 - 1
modpol_core/modules/change_modules.lua

@@ -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,
             {

+ 1 - 1
modpol_core/modules/create_token.lua

@@ -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,
             {

+ 1 - 1
modpol_core/modules/join_org_consent.lua

@@ -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, 
         {

+ 1 - 1
modpol_core/modules/remove_child_consent.lua

@@ -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,
                {

+ 1 - 1
modpol_core/modules/remove_member_consent.lua

@@ -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,
                {

+ 1 - 1
modpol_core/modules/remove_org_consent.lua

@@ -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, 
         {

+ 3 - 3
modpol_core/modules/remove_process.lua

@@ -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

+ 1 - 1
modpol_core/modules/rename_org_consent.lua

@@ -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, 
             {

+ 1 - 1
modpol_core/modules/tokenomics.lua

@@ -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,
             {

+ 12 - 0
modpol_core/orgs/process.lua

@@ -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