moving how pending actions work around, after some testing and discussion. reordered how new processes are created so that they have access to their own ids
This commit is contained in:
@@ -14,6 +14,7 @@ function temp_org()
|
||||
policies = {},
|
||||
processes = {},
|
||||
requests = {},
|
||||
pending = {},
|
||||
members = {},
|
||||
parent = nil,
|
||||
children = {}
|
||||
|
||||
@@ -13,10 +13,6 @@ function modpol.orgs:create_process(process_type, request_id)
|
||||
return
|
||||
end
|
||||
|
||||
-- retrieving requested module
|
||||
local module = modpol.modules[process_type]
|
||||
local new_process = module:new_process(request_id, self.id)
|
||||
|
||||
-- linear search for empty process slots (lazy deletion)
|
||||
for k, v in ipairs(self.processes) do
|
||||
if v == 'deleted' then
|
||||
@@ -28,17 +24,33 @@ function modpol.orgs:create_process(process_type, request_id)
|
||||
local index
|
||||
-- attempts to fill empty spots in list, otherwise appends to end
|
||||
if empty_index then
|
||||
self.processes[empty_index] = new_process
|
||||
index = empty_index
|
||||
else
|
||||
table.insert(self.processes, new_process)
|
||||
index = #self.processes
|
||||
index = #self.processes + 1
|
||||
end
|
||||
|
||||
new_process.id = index
|
||||
-- retrieving requested module
|
||||
local module = modpol.modules[process_type]
|
||||
local new_process = module:new_process(index, request_id, self.id)
|
||||
|
||||
self.processes[index] = new_process
|
||||
|
||||
return index
|
||||
end
|
||||
|
||||
-- ===========================
|
||||
-- adds a new pending action to the org's table
|
||||
function modpol.orgs:add_pending_action(user, process_id, action)
|
||||
self.pending[user][process_id] = action
|
||||
|
||||
-- pending = {
|
||||
-- ['lukvmil']={
|
||||
-- [1]='approve'
|
||||
-- }
|
||||
-- }
|
||||
|
||||
end
|
||||
|
||||
-- ===========================
|
||||
-- compares to requests to see if they are identical
|
||||
function modpol.orgs.comp_req(req1, req2)
|
||||
|
||||
Reference in New Issue
Block a user