remove_org_consent.lua 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. --- Remove org (consent)
  2. -- A simple module that calls a consent process on an org to remove it.
  3. -- Depends on the Consent module.
  4. local remove_org_consent = {
  5. name = "Remove this org (consent)",
  6. slug = "remove_org_consent",
  7. desc = "Removes an org if all members consent."
  8. }
  9. remove_org_consent.data = {
  10. result = nil
  11. }
  12. remove_org_consent.config = {
  13. }
  14. function remove_org_consent:initiate(result)
  15. if self.org == modpol.instance then
  16. modpol.interactions.message(
  17. self.initiator,
  18. "Cannot remove root org")
  19. if result then result() end
  20. self.org:delete_process(self.id)
  21. else
  22. self.data.result = result
  23. self.org:call_module(
  24. "consent",
  25. self.initiator,
  26. {
  27. prompt = "Remove org " .. self.org.name .. "?",
  28. votes_required = #self.org.members
  29. },
  30. function ()
  31. self:complete()
  32. end
  33. )
  34. modpol.interactions.org_dashboard(
  35. self.initiator, self.org.name)
  36. end
  37. end
  38. function remove_org_consent:complete()
  39. modpol.interactions.message_org(
  40. self.initiator, self.org.id,
  41. "Consent reached: removing org " .. self.org.name)
  42. if self.data.result then self.data.result() end
  43. self.org:delete_process(self.id)
  44. self.org:delete()
  45. end
  46. modpol.modules.remove_org_consent = remove_org_consent