Non-functioning start on module stratey #1
This commit is contained in:
parent
48058a05b3
commit
e96b8641dc
@ -1,10 +1,47 @@
|
||||
modpol.orgs.request_params = {
|
||||
add_org = 1,
|
||||
delete = 0,
|
||||
add_member = 1,
|
||||
remove_member = 1
|
||||
-- REQUESTS
|
||||
-- Provides request functionality to org
|
||||
|
||||
-- TODO
|
||||
-- include consent functionality, available to modules
|
||||
-- load available modules in modpol.lua
|
||||
-- make policies a set of options for consent functions
|
||||
-- create simple modules for core functions: change_policy, add_member, start_org, join_org, close_org
|
||||
|
||||
-- CONSENT
|
||||
-- Provides consent functionality for modules
|
||||
|
||||
-- define default params
|
||||
modpol.default_policy = {
|
||||
target_org = nil,
|
||||
time_limit = nil,
|
||||
vote_threshold = 0
|
||||
}
|
||||
|
||||
-- Function: modpol.orgs:consent(params, result_function)
|
||||
-- params: table of optional preferences, e.g.:
|
||||
-- target_org
|
||||
-- time_limit
|
||||
-- vote_threshold (0-100 percent, 0 is automatic approval)
|
||||
-- result_function: function(input) that takes result boolean
|
||||
function modpol.orgs:consent(params, result_function)
|
||||
-- if appropriate, pass on to target org
|
||||
if params.target_org then
|
||||
local target_org = params.target_org
|
||||
params.target_org = nil
|
||||
params.target_org:consent(params, result_function)
|
||||
return
|
||||
end
|
||||
STUCK ON HOW TO IMPLEMENT THIS WITHOUT REQUIRING THE FULL PROCESS FUNCTIONALITY
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- PROCESSES
|
||||
-- functions that enable requests to create processes
|
||||
|
||||
-- ================================
|
||||
-- creates a new process linked to a request id
|
||||
function modpol.orgs:create_process(process_type, request_id)
|
||||
@ -171,19 +208,6 @@ end
|
||||
-- ================================
|
||||
-- tries to make a request to the org
|
||||
function modpol.orgs:make_request(request)
|
||||
-- makes sure the request has the valid number of parameters
|
||||
local num_params = modpol.orgs.request_params[request.type]
|
||||
|
||||
if num_params == nil then
|
||||
modpol.ocutil.log('Error in ' .. self.name .. ':make_request -> request type is invalid')
|
||||
return false
|
||||
end
|
||||
|
||||
-- request.params should match the num of params for that type
|
||||
if #request.params ~= num_params then
|
||||
modpol.ocutil.log('Error in ' .. self.name .. ':make_request -> request has invalid number of parameters')
|
||||
return false
|
||||
end
|
||||
|
||||
-- checking to see if identical request already exists
|
||||
for k, v in ipairs(self.requests) do
|
||||
|
Loading…
x
Reference in New Issue
Block a user