Browse Source

added a function to wipe all pending actions for dead processes, consent module now does this on close

Luke Miller 3 years ago
parent
commit
6de2be011f
2 changed files with 9 additions and 4 deletions
  1. 1 4
      modpol/modules/consent.lua
  2. 8 0
      modpol/orgs/requests.lua

+ 1 - 4
modpol/modules/consent.lua

@@ -44,6 +44,7 @@ end
 -- function to delete a process, called when process finishes
 function modpol.modules.consent:delete()
     local process_org = modpol.orgs.get_org(self.org_id)
+    process_org:wipe_pending_actions(self.id)
     process_org.processes[self.id] = "deleted"
     modpol.ocutil.log('Deleted process #' .. self.id)
 end
@@ -90,8 +91,4 @@ function modpol.modules.consent:update_status()
     else
         modpol.ocutil.log('Waiting for more votes...')
     end
-end
-
-function modpol.modules.consent.pending_processes()
-
 end

+ 8 - 0
modpol/orgs/requests.lua

@@ -67,6 +67,14 @@ function modpol.orgs:remove_pending_action(process_id, user, action)
     modpol.ocutil.log("Could not remove pending action '" .. action .. "' from " .. user .. " in process #" .. process_id)
 end
 
+-- =====================
+-- removes all pending actions for a given process id from all users
+function modpol.orgs:wipe_pending_actions(process_id)
+    for user in pairs(self.pending) do
+        self.pending[user][process_id] = nil
+    end
+    modpol.ocutil.log("Removed all pending actions for process #" .. process_id)
+end
 
 -- ===========================
 -- compares to requests to see if they are identical