Sha256: 8192979f4b0c3074db49111e2b060cc4110b3df337f9c71a3dec552be74cb609
Contents?: true
Size: 1.42 KB
Versions: 24
Compression:
Stored size: 1.42 KB
Contents
# frozen_string_literal: true module Decidim module Elections # The data store for a trustee in the Decidim::Elections component. It stores a # public key and has a reference to Decidim::User. class Trustee < ApplicationRecord belongs_to :user, foreign_key: "decidim_user_id", class_name: "Decidim::User" belongs_to :organization, foreign_key: "decidim_organization_id", class_name: "Decidim::Organization" has_many :elections_trustees, foreign_key: "decidim_elections_trustee_id", dependent: :destroy has_many :elections, through: :elections_trustees has_many :trustees_participatory_spaces, inverse_of: :trustee, foreign_key: "decidim_elections_trustee_id", dependent: :destroy def self.trustee?(user) exists?(user: user) end def self.log_presenter_class_for(_log) Decidim::Elections::AdminLog::TrusteePresenter end def self.for(user) find_by(user: user) end def slug name.parameterize end # The bulletin_board_slug is used as `unique_id` on the Bulletin Board, where # the "authority.name" gets added as identification. If the organization # name would be missing, it could result in an error, when two organizations # inside the same "authority" have a trustee with the same name. def bulletin_board_slug "#{organization.name.parameterize}-#{slug}" end end end end
Version data entries
24 entries across 24 versions & 1 rubygems