drafting consent module
This commit is contained in:
parent
358aacba0a
commit
68d8da7290
@ -0,0 +1,37 @@
|
|||||||
|
rough_idea = { -- a lot of these might want to call org functions instead of being hard coded
|
||||||
|
type = "consent",
|
||||||
|
org_id = 5, -- may be needed for defer_to, process sent to a diff org
|
||||||
|
request_id = 1, -- callback to request
|
||||||
|
total_votes = 2,
|
||||||
|
to_pass = 3, -- could default to majority, but could set super majority
|
||||||
|
eligible_voters = 5,
|
||||||
|
timeout = 234235325, -- timestamp when vote ends
|
||||||
|
votes_yes = {
|
||||||
|
"lukvmil"
|
||||||
|
},
|
||||||
|
votes_no = {
|
||||||
|
"nathan"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function modules.consent.cast_vote(user, decision, org_id, process_id)
|
||||||
|
local org = modpol.orgs.get_org(org_id)
|
||||||
|
local process = org:get_process(process_id)
|
||||||
|
if decision == "yes" then
|
||||||
|
table.insert(process.votes_yes, user)
|
||||||
|
elseif decision == "no" then
|
||||||
|
table.insert(process.votes_no, user)
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
|
||||||
|
process.total_votes = process.total_votes + 1
|
||||||
|
call_vote_check(process) -- some call to determine if the vote has reached an end condition
|
||||||
|
end
|
||||||
|
|
||||||
|
function modules.consent.call_vote_check(process)
|
||||||
|
if votes_yes > to_pass then
|
||||||
|
call_success()
|
||||||
|
elseif votes_no > to_pass then
|
||||||
|
call_failure()
|
||||||
|
end
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user