Class: Decidim::Elections::Trustee

Inherits:
ApplicationRecord show all
Defined in:
decidim-elections/app/models/decidim/elections/trustee.rb

Overview

The data store for a trustee in the Decidim::Elections component. It stores a public key and has a reference to Decidim::User.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.for(user) ⇒ Object



22
23
24
# File 'decidim-elections/app/models/decidim/elections/trustee.rb', line 22

def self.for(user)
  find_by(user:)
end

.log_presenter_class_for(_log) ⇒ Object



18
19
20
# File 'decidim-elections/app/models/decidim/elections/trustee.rb', line 18

def self.log_presenter_class_for(_log)
  Decidim::Elections::AdminLog::TrusteePresenter
end

.trustee?(user) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'decidim-elections/app/models/decidim/elections/trustee.rb', line 14

def self.trustee?(user)
  exists?(user:)
end

Instance Method Details

#bulletin_board_slugObject

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.



34
35
36
# File 'decidim-elections/app/models/decidim/elections/trustee.rb', line 34

def bulletin_board_slug
  "#{organization.name.parameterize}-#{slug}"
end

#slugObject



26
27
28
# File 'decidim-elections/app/models/decidim/elections/trustee.rb', line 26

def slug
  name.parameterize
end