bugfixes to get delete and add_org requests to work. Working!

This commit is contained in:
Nathan Schneider
2021-08-04 22:47:02 -06:00
parent fa4283dce6
commit c26f11cd99
4 changed files with 30 additions and 33 deletions

View File

@@ -70,11 +70,11 @@ 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)
self:record('Removed all pending actions for process #' .. process_id, "del_pending_action")
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)
self:record('Removed all pending actions for process #' .. process_id, "del_pending_action")
end
-- ======================
@@ -129,10 +129,15 @@ end
-- ===============================
-- if the request was approved, the associated function is called, otherwise it is deleted
-- TODO Rather than hard-coding functions below, this should be given an arbitrary result function based on the request
function modpol.orgs:resolve_request(request_id, approve)
if approve then
local request = self.requests[request_id]
local p = request.params
-- wipe actions
self:wipe_pending_actions(request_id)
if approve then
local request = self.requests[request_id]
local p = request.params
-- there's probably a way to clean this up, the issue is the varying number of commands
-- ex: self['add_member'](self, 'member_name')
@@ -151,10 +156,13 @@ function modpol.orgs:resolve_request(request_id, approve)
end
end
self.requests[request_id] = "deleted"
self.processes[request_id] = "deleted"
modpol.ocutil.log('Deleted process #' .. request_id)
self.requests[request_id] = "deleted"
modpol.ocutil.log("Resolved request #" .. request_id .. ' in ' .. self.name)
self:record("Resolved request #" .. request_id, "resolve_request")
end
@@ -188,8 +196,8 @@ function modpol.orgs:make_request(request)
-- if not the instance org (instance's don't have parents)
if self.id ~= 1 then
local parent_policy = modpol.orgs.get_org(self.parent).policies[request.type]
local parent_policy = modpol.orgs.get_org(self.parent).policies[request.type]
-- tries to use org's policy table, defers to parent otherwise
if not requested_policy then
modpol.ocutil.log(request.type .. ' policy not found, deferring to parent org')