Class: Decidim::Proposals::ProposalType
- Inherits:
-
Api::Types::BaseObject
- Object
- Api::Types::BaseObject
- Decidim::Proposals::ProposalType
- Includes:
- ActiveSupport::NumberHelper
- Defined in:
- lib/decidim/api/proposal_type.rb
Class Method Summary collapse
Instance Method Summary collapse
- #answer ⇒ Object
- #answered_at ⇒ Object
- #cost ⇒ Object
- #cost_report ⇒ Object
- #execution_period ⇒ Object
- #meeting ⇒ Object
- #url ⇒ Object
- #vote_count ⇒ Object
Class Method Details
.authorized?(object, context) ⇒ Boolean
91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/decidim/api/proposal_type.rb', line 91 def self.(object, context) context[:proposal] = object chain = [ allowed_to?(:read, :proposal, object, context), object.published? ].all? super && chain rescue Decidim::PermissionAction::PermissionNotSetError false end |
Instance Method Details
#answer ⇒ Object
56 57 58 59 60 |
# File 'lib/decidim/api/proposal_type.rb', line 56 def answer return unless object.published_state? object.answer end |
#answered_at ⇒ Object
50 51 52 53 54 |
# File 'lib/decidim/api/proposal_type.rb', line 50 def answered_at return unless object.published_state? object.answered_at end |
#cost ⇒ Object
80 81 82 83 84 85 |
# File 'lib/decidim/api/proposal_type.rb', line 80 def cost return unless object.published_state? return unless proposal_has_costs? && current_settings.answers_with_costs? number_to_currency(object.cost, unit: Decidim.currency_unit) end |
#cost_report ⇒ Object
66 67 68 69 70 71 |
# File 'lib/decidim/api/proposal_type.rb', line 66 def cost_report return unless object.published_state? return unless proposal_has_costs? && current_settings.answers_with_costs? object.cost_report end |
#execution_period ⇒ Object
73 74 75 76 77 78 |
# File 'lib/decidim/api/proposal_type.rb', line 73 def execution_period return unless object.published_state? return unless proposal_has_costs? && current_settings.answers_with_costs? object.execution_period end |
#meeting ⇒ Object
62 63 64 |
# File 'lib/decidim/api/proposal_type.rb', line 62 def meeting object..first if object.official_meeting? end |
#url ⇒ Object
46 47 48 |
# File 'lib/decidim/api/proposal_type.rb', line 46 def url Decidim::ResourceLocatorPresenter.new(object).url end |
#vote_count ⇒ Object
87 88 89 |
# File 'lib/decidim/api/proposal_type.rb', line 87 def vote_count object.proposal_votes_count unless current_settings.votes_hidden? end |