|
@@ -6,6 +6,31 @@
|
|
|
-- TKTK may need to create high-level modpol.processes table to hold ongoing processes
|
|
|
-- TKTK in order to enable async processes. Rewrite all this as listeners
|
|
|
|
|
|
+-- ===================================================================
|
|
|
+-- Function: modpol.switchboard
|
|
|
+-- Params: org (string), routine (string)
|
|
|
+-- Outputs: Checks the org for any policies related to a given function;
|
|
|
+-- Calls the modpol.initiate.* function(org) based on policy
|
|
|
+-- Defaults to modpol.initiate.consent()
|
|
|
+modpol.switchboard = function(org, routine)
|
|
|
+ if modpol.orgs[org]["policies"]
|
|
|
+ and modpol.orgs[org]["policies"][routine] then
|
|
|
+ -- TKTK if there exists a policy, initiate that function
|
|
|
+ else
|
|
|
+ modpol.initiate.consent(org)
|
|
|
+ end
|
|
|
+end
|
|
|
+
|
|
|
+-- ===================================================================
|
|
|
+-- TKTK
|
|
|
+-- Function: modpol.delegate
|
|
|
+-- Delegates a process from one org to another
|
|
|
+
|
|
|
+
|
|
|
+-- ===================================================================
|
|
|
+-- Basic decision functions
|
|
|
+-- ===================================================================
|
|
|
+
|
|
|
-- ===================================================================
|
|
|
-- Function: modpol.consent
|
|
|
-- Params: org (string), proposal (string)
|
|
@@ -30,6 +55,26 @@ modpol.consent = function(org, query)
|
|
|
return true, responses
|
|
|
end
|
|
|
|
|
|
+-- ===================================================================
|
|
|
+-- Function: modpol.approved
|
|
|
+-- A simple function for automatically approved processes
|
|
|
+-- Params: none
|
|
|
+-- Outputs: boolean - true
|
|
|
+modpol.approved = function()
|
|
|
+ -- Check that org exists
|
|
|
+ if modpol.orgs[org] == nil then
|
|
|
+ return nil, "Error: Org does not exist"
|
|
|
+ end
|
|
|
+ return true
|
|
|
+end
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+-- ===================================================================
|
|
|
+-- Experimental
|
|
|
+-- ===================================================================
|
|
|
+
|
|
|
+-- ===================================================================
|
|
|
-- TKTK exploring modpol.initiate functions, which have no args
|
|
|
-- Need to properly document these
|
|
|
modpol.initiate = {}
|
|
@@ -39,17 +84,3 @@ modpol.initiate.consent = function(org)
|
|
|
local query = io.read()
|
|
|
return modpol.consent(org, query)
|
|
|
end
|
|
|
-
|
|
|
--- Function: modpol.switchboard
|
|
|
--- Params: org (string), routine (string)
|
|
|
--- Outputs: Checks the org for any policies related to a given function;
|
|
|
--- Calls the modpol.initiate.* function(org) based on policy
|
|
|
--- Defaults to modpol.initiate.consent()
|
|
|
-modpol.switchboard = function(org, routine)
|
|
|
- if modpol.orgs[org]["policies"]
|
|
|
- and modpol.orgs[org]["policies"][routine] then
|
|
|
- -- TKTK if there exists a policy
|
|
|
- else
|
|
|
- modpol.initiate.consent(org)
|
|
|
- end
|
|
|
-end
|