Sha256: 50898198a1be8b2ceb2cce33cba98c84728d164f06b70ccc17ffdf5650ce1324

Contents?: true

Size: 825 Bytes

Versions: 6

Compression:

Stored size: 825 Bytes

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"
      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.for(user)
        find_by(user: user)
      end

      def unique_id
        name.parameterize
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
decidim-elections-0.24.3 app/models/decidim/elections/trustee.rb
decidim-elections-0.24.2 app/models/decidim/elections/trustee.rb
decidim-elections-0.24.1 app/models/decidim/elections/trustee.rb
decidim-elections-0.24.0 app/models/decidim/elections/trustee.rb
decidim-elections-0.24.0.rc2 app/models/decidim/elections/trustee.rb
decidim-elections-0.24.0.rc1 app/models/decidim/elections/trustee.rb