diff options
author | hellekin <hellekin@cepheide.org> | 2021-01-22 05:32:15 +0100 |
---|---|---|
committer | hellekin <hellekin@cepheide.org> | 2021-01-22 05:32:15 +0100 |
commit | b54a8458d5029b3494165b7430e21b3ae34ecc0c (patch) | |
tree | 32ea6fc6b8774f672325fec52f0ffc97229a9568 /app/models/agency.rb | |
parent | 1c1aead78192982e221179de6688b944e5b01bf6 (diff) | |
download | incommon-map-b54a8458d5029b3494165b7430e21b3ae34ecc0c.tar.gz |
Upgrade Rails and add StimulusJS support
Diffstat (limited to 'app/models/agency.rb')
-rw-r--r-- | app/models/agency.rb | 28 |
1 files changed, 0 insertions, 28 deletions
diff --git a/app/models/agency.rb b/app/models/agency.rb index 7ffe489..842e8bd 100644 --- a/app/models/agency.rb +++ b/app/models/agency.rb @@ -3,34 +3,6 @@ # SPDX-License-Identifier: AGPL-3.0-or-later class Agency < ApplicationRecord - include Bitfields - belongs_to :agent belongs_to :user - - bitfield :roles, :observer, :editor, :maintainer, :leader - - class << self - # Grant role in agent to user - def grant(agent, user, role) - r = find_or_create_by(agent: agent, user: user) - r&.public_send("#{role}=", true) && r&.save - end - - # Revoke role in agent from user - def revoke(agent, user, role) - r = find_by(agent: agent, user: user) - r&.public_send("#{role}=", false) && r&.save - end - end - - # Grant role to current user in current agent - def grant(role) - self.class.grant(agent, user, role) - end - - # Revoke role from current user in current agent - def revoke(role) - self.class.revoke(agent, user, role) - end end |