Added modpol.approved and modpol.add_policy functions

This commit is contained in:
2021-02-11 21:59:17 +00:00
parent b6ac30ee72
commit 6a6220b253
2 changed files with 76 additions and 17 deletions

View File

@@ -185,10 +185,38 @@ function modpol.remove_member(org, member)
end
-- ===================================================================
-- TKTK:
-- + rename_org(old_name, new_name)
-- +
-- TKTK
-- rename_org(old_name, new_name)
-- Renames an org
-- ===================================================================
-- modpol.add_policy
-- Adds a policy to an org's [org].policies table
-- Params: org_name (string), target_function (string),
-- policy_function (string)
-- function names should be in the form [module?.][function]
-- and can be modpol.delegate(org_name)
-- Output: true if successful, nil if error
modpol.add_policy = function(org_name, target_function, policy_function)
-- first, basic checks
local message = "Error: No such org"
if (modpol.orgs[org_name] == nil) then
return nil, message
elseif (modpol[target_function] == nil) then
message = "Error: No such target function"
return nil, message
elseif (modpol[policy_function]) then
message = "Error: No such policy function"
return nil, message
else
-- okay, proceed
modpol.orgs[org_name].policies[target_function] = policy_function
message = "In org " .. org_name .. ", policy for " .. target_function
.. " set to " .. policy_function
record(org_name, message)
return true, message
end
end
-- ===================================================================
-- End of file.