beginning to reimplement policy code
This commit is contained in:
parent
06dd824f35
commit
201fb98229
@ -275,6 +275,42 @@ function modpol.orgs:list_member()
|
||||
return str
|
||||
end
|
||||
|
||||
-- ====================================
|
||||
-- adds a new policy to the policy table
|
||||
-- must define the policy type, process associated with it, and whether the request must be made by an org member
|
||||
function modpol.orgs:set_policy(policy_type, process, must_be_member)
|
||||
local new_policy = {
|
||||
process = process,
|
||||
must_be_member = must_be_member
|
||||
}
|
||||
self.policies[policy_type] = policy
|
||||
end
|
||||
|
||||
|
||||
-- ================================
|
||||
--
|
||||
function modpol.orgs:create_process(request_id)
|
||||
local new_process = {
|
||||
object = "I am a process",
|
||||
request_id = request_id
|
||||
}
|
||||
|
||||
-- linear search for empty process slots (lazy deletion)
|
||||
for k, v in ipairs(self.processes) do
|
||||
if v == 'deleted' then
|
||||
local empty_index = k
|
||||
break
|
||||
do
|
||||
end
|
||||
|
||||
-- attempts to fill empty spots in list, otherwise appends to end
|
||||
if empty_index then
|
||||
self.processes[index] = new_process
|
||||
else
|
||||
table.insert(self.processes, new_process)
|
||||
end
|
||||
end
|
||||
|
||||
-- ===========================
|
||||
-- compares to requests to see if they are identical
|
||||
function modpol.orgs.comp_req(req1, req2)
|
||||
@ -303,7 +339,8 @@ function modpol.orgs:make_request(request)
|
||||
modpol.ocutil.log("Error: request type is invalid")
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
-- num_params should equal zero at the end if request.params matches the num of params for that type
|
||||
for k, v in ipairs(request.params) do
|
||||
num_params = num_params - 1
|
||||
end
|
||||
@ -321,6 +358,11 @@ function modpol.orgs:make_request(request)
|
||||
end
|
||||
end
|
||||
|
||||
local requested_policy = self.policies[request.type]
|
||||
if requested_policy then
|
||||
|
||||
end
|
||||
|
||||
-- use lazy deletion here, not very clean
|
||||
-- table.insert(self.requests, request)
|
||||
self.request_count = self.request_count + 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user