orgs are now initialized with a founding member
This commit is contained in:
@@ -144,7 +144,7 @@ end
|
||||
-- ==================================================
|
||||
-- adds a new sub org to the org it is called on
|
||||
-- ex: instance:add_org('town hall')
|
||||
function modpol.orgs:add_org(name)
|
||||
function modpol.orgs:add_org(name, user)
|
||||
if self.id == nil then
|
||||
modpol.ocutil.log('Error in ' .. self.name .. ':add_org -> add_org can only be called by another org')
|
||||
return false
|
||||
@@ -175,6 +175,9 @@ function modpol.orgs:add_org(name)
|
||||
-- adding child to org list
|
||||
modpol.orgs.array[child_org.id] = child_org
|
||||
|
||||
-- adding creator of org as the first member
|
||||
child_org:add_member(user)
|
||||
|
||||
self:record('created sub org ' .. name, 'add_org')
|
||||
modpol.ocutil.log('Created ' .. name .. ' (suborg of ' .. self.name .. ')')
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
modpol.orgs.request_params = {
|
||||
add_org = 1,
|
||||
add_org = 2,
|
||||
delete = 0,
|
||||
add_member = 1,
|
||||
remove_member = 1
|
||||
@@ -79,6 +79,7 @@ function modpol.orgs:resolve_request(request_id, approve)
|
||||
-- there's probably a way to clean this up, the issue is the varying number of commands
|
||||
-- ex: self['add_member'](self, 'member_name')
|
||||
-- not sure if this is safe, more testing to do
|
||||
print(p[1], p[2])
|
||||
self[request.type](self, p[1], p[2], p[3])
|
||||
|
||||
-- if request.type == "add_org" then
|
||||
@@ -127,15 +128,26 @@ function modpol.orgs:make_request(request)
|
||||
|
||||
-- checking to see if user is able to make request
|
||||
local requested_policy = self.policies[request.type]
|
||||
local parent_policy = modpol.orgs.get_org(self.parent).policies[request.type]
|
||||
|
||||
-- tries to use org's policy table, defers to parent otherwise
|
||||
if not requested_policy then
|
||||
modpol.ocutil.log(request.type .. ' policy not found, deferring to parent org')
|
||||
requested_policy = parent_policy
|
||||
-- if not the instance org (instance's don't have parents)
|
||||
if self.id ~= 1 then
|
||||
local parent_policy = modpol.orgs.get_org(self.parent).policies[request.type]
|
||||
|
||||
if not parent_policy then
|
||||
modpol.ocutil.log('Error in ' .. self.name .. ':make_request -> parent policy undefined')
|
||||
-- tries to use org's policy table, defers to parent otherwise
|
||||
if not requested_policy then
|
||||
modpol.ocutil.log(request.type .. ' policy not found, deferring to parent org')
|
||||
requested_policy = parent_policy
|
||||
|
||||
if not parent_policy then
|
||||
modpol.ocutil.log('Error in ' .. self.name .. ':make_request -> parent policy undefined')
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
-- fails if instance policy undefined
|
||||
else
|
||||
if not requested_policy then
|
||||
modpol.ocutil.log('Error in ' .. self.name .. ':make_request -> policy undefined')
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user