Class: Decidim::Proposals::Proposal
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Decidim::Proposals::Proposal
- Includes:
- Authorable, HasCategory, HasFeature, HasScope, Resourceable
- Defined in:
- app/models/decidim/proposals/proposal.rb
Overview
The data store for a Proposal in the Decidim::Proposals component.
Instance Method Summary collapse
-
#accepted? ⇒ Boolean
Public: Checks if the organization has accepted a proposal.
-
#answered? ⇒ Boolean
Public: Checks if the organization has given an answer for the proposal.
- #author_avatar_url ⇒ Object
- #author_name ⇒ Object
-
#rejected? ⇒ Boolean
Public: Checks if the organization has rejected a proposal.
-
#voted_by?(user) ⇒ Boolean
Public: Check if the user has voted the proposal.
Instance Method Details
#accepted? ⇒ Boolean
Public: Checks if the organization has accepted a proposal.
Returns Boolean.
46 47 48 |
# File 'app/models/decidim/proposals/proposal.rb', line 46 def accepted? state == "accepted" end |
#answered? ⇒ Boolean
Public: Checks if the organization has given an answer for the proposal.
Returns Boolean.
39 40 41 |
# File 'app/models/decidim/proposals/proposal.rb', line 39 def answered? answered_at.present? end |
#author_avatar_url ⇒ Object
25 26 27 |
# File 'app/models/decidim/proposals/proposal.rb', line 25 def &.avatar&.url || ActionController::Base.helpers.asset_path("decidim/default-avatar.svg") end |
#author_name ⇒ Object
21 22 23 |
# File 'app/models/decidim/proposals/proposal.rb', line 21 def user_group&.name || &.name || I18n.t("decidim.proposals.models.proposal.fields.official_proposal") end |
#rejected? ⇒ Boolean
Public: Checks if the organization has rejected a proposal.
Returns Boolean.
53 54 55 |
# File 'app/models/decidim/proposals/proposal.rb', line 53 def rejected? state == "rejected" end |
#voted_by?(user) ⇒ Boolean
Public: Check if the user has voted the proposal.
Returns Boolean.
32 33 34 |
# File 'app/models/decidim/proposals/proposal.rb', line 32 def voted_by?(user) votes.any? { |vote| vote. == user } end |