added ledger records and data saving for all valid org actions, updated storage code to not text dump
This commit is contained in:
parent
ebc2f4758e
commit
87f4b6a2fe
@ -311,6 +311,7 @@ function modpol.orgs:set_policy(policy_type, process_type, must_be_member)
|
||||
}
|
||||
self.policies[policy_type] = new_policy
|
||||
modpol.ocutil.log('Added policy for ' .. policy_type .. ' in ' .. self.name)
|
||||
self:record('Added policy for ' .. policy_type, 'set_policy')
|
||||
end
|
||||
|
||||
|
||||
|
@ -35,6 +35,9 @@ function modpol.orgs:create_process(process_type, request_id)
|
||||
|
||||
self.processes[index] = new_process
|
||||
|
||||
modpol.ocutil.log('Created process #' .. index .. ' - ' .. process_type .. ' for ' .. self.name)
|
||||
self:record('Created process #' .. index .. ' - ' .. process_type, 'add_process')
|
||||
|
||||
return index
|
||||
end
|
||||
|
||||
@ -46,7 +49,8 @@ function modpol.orgs:add_pending_action(process_id, user)
|
||||
-- flagging actual action
|
||||
self.pending[user][process_id] = true
|
||||
|
||||
modpol.ocutil.log("Added pending action to " .. user .. " in process #" .. process_id)
|
||||
modpol.ocutil.log("Added pending action to " .. user .. " in process #" .. process_id .. ' from ' .. self.name)
|
||||
self:record('Added pending action to ' .. user .. ' in process #' .. process_id, "add_pending_action")
|
||||
end
|
||||
|
||||
-- ========================
|
||||
@ -55,7 +59,8 @@ function modpol.orgs:remove_pending_action(process_id, user)
|
||||
|
||||
if self.pending[user] then
|
||||
self.pending[user][process_id] = nil
|
||||
modpol.ocutil.log("Removed pending action from " .. user .. " in process #" .. process_id)
|
||||
modpol.ocutil.log("Removed pending action from " .. user .. " in process #" .. process_id .. ' from ' .. self.name)
|
||||
self:record('Removed pending action from ' .. user .. ' in process #' .. process_id, "del_pending_action")
|
||||
else
|
||||
modpol.ocutil.log("Could not remove pending action from " .. user .. " in process #" .. process_id)
|
||||
end
|
||||
@ -68,6 +73,7 @@ function modpol.orgs:wipe_pending_actions(process_id)
|
||||
self.pending[user][process_id] = nil
|
||||
end
|
||||
modpol.ocutil.log("Removed all pending actions for process #" .. process_id)
|
||||
self:record('Removed all pending actions for process #' .. process_id, "del_pending_action")
|
||||
end
|
||||
|
||||
-- ======================
|
||||
@ -146,6 +152,9 @@ function modpol.orgs:resolve_request(request_id, approve)
|
||||
end
|
||||
|
||||
self.requests[request_id] = "deleted"
|
||||
|
||||
modpol.ocutil.log("Resolved request #" .. request_id .. ' in ' .. self.name)
|
||||
self:record("Resolved request #" .. request_id, "resolve_request")
|
||||
end
|
||||
|
||||
-- ================================
|
||||
@ -222,7 +231,8 @@ function modpol.orgs:make_request(request)
|
||||
table.insert(self.requests, request)
|
||||
request_id = #self.requests
|
||||
end
|
||||
modpol.ocutil.log("Request made by " .. request.user .. " to " .. request.type)
|
||||
modpol.ocutil.log("Request made by " .. request.user .. " to " .. request.type .. " in " .. self.name)
|
||||
self:record("Request made by " .. request.user .. " to " .. request.type, "make_request")
|
||||
|
||||
-- launching process tied to this request
|
||||
local process_id = self:create_process(requested_policy.process_type, request_id)
|
||||
|
@ -25,18 +25,17 @@ dofile (modpol.topdir .. "/util/serpent/serpent.lua")
|
||||
-- ===================================================================
|
||||
-- This function stores "ledger" data to disk.
|
||||
|
||||
local store_ledger = function()
|
||||
local ok = modpol.ocutil.file_write (modpol.file_ledger,
|
||||
modpol.serpent.dump (modpol.ledger))
|
||||
local store_ledger = function(verbose)
|
||||
local ok = modpol.ocutil.file_write (modpol.file_ledger, modpol.serpent.dump (modpol.ledger))
|
||||
|
||||
if ok ~= true then
|
||||
if ok ~= true then
|
||||
modpol.ocutil.fatal_error ("store_data: ledger")
|
||||
end
|
||||
|
||||
local nn = modpol.ocutil.table_length (modpol.ledger)
|
||||
local nn = modpol.ocutil.table_length (modpol.ledger)
|
||||
local str = "entries"
|
||||
if nn == 1 then str = "entry" end
|
||||
modpol.ocutil.log (nn .. " global ledger entries stored to disk")
|
||||
if verbose then modpol.ocutil.log (nn .. " global ledger entries stored to disk") end
|
||||
end
|
||||
|
||||
-- ===================================================================
|
||||
@ -52,35 +51,16 @@ local store_orgs = function()
|
||||
local nn = modpol.ocutil.table_length (modpol.orgs.array)
|
||||
local str = "entries"
|
||||
if nn == 1 then str = "entry" end
|
||||
modpol.ocutil.log (nn .. " orgs stored to disk")
|
||||
if verbose then modpol.ocutil.log (nn .. " orgs stored to disk") end
|
||||
end
|
||||
|
||||
-- ===================================================================
|
||||
-- This function stores "old_ledgers" data to disk.
|
||||
|
||||
local store_old_ledgers = function()
|
||||
|
||||
local ok = modpol.ocutil.file_write (modpol.file_old_ledgers,
|
||||
modpol.serpent.dump (modpol.old_ledgers))
|
||||
|
||||
|
||||
if ok ~= true then
|
||||
modpol.ocutil.fatal_error ("store_data: orgs")
|
||||
end
|
||||
|
||||
local nn = modpol.ocutil.table_length (modpol.old_ledgers)
|
||||
local str = "entries"
|
||||
if nn == 1 then str = "entry" end
|
||||
modpol.ocutil.log (nn .. " orgs stored to disk")
|
||||
end
|
||||
|
||||
-- ===================================================================
|
||||
-- This function stores data to disk.
|
||||
|
||||
modpol.store_data = function()
|
||||
store_ledger()
|
||||
store_orgs()
|
||||
-- store_old_ledgers()
|
||||
modpol.store_data = function(verbose)
|
||||
store_ledger(verbose)
|
||||
store_orgs(verbose)
|
||||
end
|
||||
|
||||
-- ===================================================================
|
||||
|
Loading…
x
Reference in New Issue
Block a user