|
@@ -3,28 +3,50 @@
|
|
|
-- Process-related functions for Modular Politics
|
|
|
-- Called by modpol.lua
|
|
|
|
|
|
--- 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
|
|
|
+-- ===================================================================
|
|
|
+-- modpol.processes, a high-level table of active processes
|
|
|
+-- Process table structure:
|
|
|
+-- [name]: unique name
|
|
|
+-- [org]: org
|
|
|
+-- [update_functions]: table of available update functions
|
|
|
+-- [state]: table of relevant data on the state of the function
|
|
|
+
|
|
|
+modpol.processes = {}
|
|
|
+
|
|
|
+-- ===================================================================
|
|
|
+-- Function: modpol.register_process
|
|
|
+-- Adds a process to modpol.processes
|
|
|
|
|
|
-- ===================================================================
|
|
|
--- Function: modpol.switchboard
|
|
|
--- Params: org (string), routine (string)
|
|
|
--- Outputs: Checks the org for any policies related to a given function;
|
|
|
+-- Function: modpol.delegate_process
|
|
|
+-- Delegates a process from one org to another
|
|
|
+
|
|
|
+-- ===================================================================
|
|
|
+-- Function: modpol.begin_process
|
|
|
+-- Params: user (string), org (string), action (string)
|
|
|
+-- Outputs: Checks the org for any policies related to a given action;
|
|
|
-- 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
|
|
|
+modpol.begin_process = function(user, org, action)
|
|
|
+ if modpol.orgs[org]["policies"]
|
|
|
+ and modpol.orgs[org]["policies"][routine] then
|
|
|
+ -- check user org membership is satisfied
|
|
|
+ -- register process
|
|
|
+ -- start the appropriate process
|
|
|
+ else
|
|
|
+ -- register process (or does .initiate.* do that?)
|
|
|
+ modpol.initiate.consent(org)
|
|
|
+ end
|
|
|
end
|
|
|
|
|
|
-- ===================================================================
|
|
|
--- TKTK
|
|
|
--- Function: modpol.delegate
|
|
|
--- Delegates a process from one org to another
|
|
|
+-- Function: modpol.update_process
|
|
|
+
|
|
|
+-- ===================================================================
|
|
|
+-- Function: modpol.end_process
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
-- ===================================================================
|
|
@@ -68,8 +90,6 @@ modpol.approved = function()
|
|
|
return true
|
|
|
end
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-- ===================================================================
|
|
|
-- Experimental
|
|
|
-- ===================================================================
|