bugfixes to get delete and add_org requests to work. Working!

This commit is contained in:
Nathan Schneider
2021-08-04 22:47:02 -06:00
parent fa4283dce6
commit c26f11cd99
4 changed files with 30 additions and 33 deletions

View File

@@ -46,29 +46,20 @@ function modpol.modules.consent:interact(user)
modpol.interactions.binary_poll_user(
user, "Do you consent?",
function(vote)
if vote == 'yes' then
if vote == 'Yes' then
self:approve(user, true)
elseif vote == 'no' then
elseif vote == 'No' then
self:approve(user, false)
end
end)
end
-- =========================================
-- function to delete a process, called when process finishes
function modpol.modules.consent:delete()
local process_org = modpol.orgs.get_org(self.org_id)
process_org:wipe_pending_actions(self.id)
process_org.processes[self.id] = "deleted"
modpol.ocutil.log('Deleted process #' .. self.id)
end
-- ======================================================
-- function for users to vote on a pending request
function modpol.modules.consent:approve(user, decision)
if not modpol.orgs.get_org(self.org_id):has_member(user) then
modpol.ocutil.log('Error in consent:approve -> user not a member of the org')
return
if not modpol.orgs.get_org(self.org_id):has_member(user) then
modpol.ocutil.log('Error in consent:approve -> user not a member of the org')
return
end
if decision then
@@ -97,11 +88,9 @@ function modpol.modules.consent:update_status()
if #self.votes_yes >= votes_needed then
modpol.ocutil.log('Request #' .. self.request_id .. ' passes')
process_org:resolve_request(self.request_id, true)
self:delete()
elseif #self.votes_no >= votes_needed then
modpol.ocutil.log('Request #' .. self.request_id .. ' fails to pass')
process_org:resolve_request(self.request_id, false)
self:delete()
else
modpol.ocutil.log('Waiting for more votes...')
end