A bunch of module bugfixes
This commit is contained in:
@ -8,7 +8,7 @@ local consent = {
|
||||
}
|
||||
|
||||
consent.data = {
|
||||
votes = 0
|
||||
votes = 0
|
||||
}
|
||||
|
||||
consent.config = {
|
||||
@ -16,11 +16,12 @@ consent.config = {
|
||||
votes_required = 1
|
||||
}
|
||||
|
||||
function consent:initiate(config, result)
|
||||
self.result = result
|
||||
function consent:initiate(result)
|
||||
self.data.result = result
|
||||
-- if org is empty, consent is given automatically
|
||||
if self.org:get_member_count() == 0 then
|
||||
self.result()
|
||||
if self.data.result then
|
||||
self.data.result() end
|
||||
self.org:wipe_pending_actions(self.id)
|
||||
else
|
||||
-- otherwise, create poll
|
||||
@ -39,14 +40,14 @@ function consent:callback(member)
|
||||
if resp == "Yes" then
|
||||
self.data.votes = self.data.votes + 1
|
||||
end
|
||||
|
||||
if self.data.votes >= self.config.votes_required then
|
||||
if self.data.result then
|
||||
self.data.result() end
|
||||
self.org:wipe_pending_actions(self.id)
|
||||
if self.result then self.result() end
|
||||
self.org:delete_process(self.id)
|
||||
end
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
modpol.modules.consent = consent
|
||||
|
Reference in New Issue
Block a user