app/models/decidim/proposals/proposal.rb in decidim-proposals-0.0.5 vs app/models/decidim/proposals/proposal.rb in decidim-proposals-0.0.6

- old
+ new

@@ -5,22 +5,26 @@ class Proposal < Proposals::ApplicationRecord include Decidim::Resourceable include Decidim::Authorable include Decidim::HasFeature include Decidim::HasScope + include Decidim::HasReference include Decidim::HasCategory + include Decidim::Reportable include Decidim::Comments::Commentable feature_manifest_name "proposals" has_many :votes, foreign_key: "decidim_proposal_id", class_name: ProposalVote, dependent: :destroy, counter_cache: "proposal_votes_count" validates :title, :body, presence: true - scope :accepted, -> { where(state: "accepted") } - scope :rejected, -> { where(state: "rejected") } + geocoded_by :address, http_headers: lambda { |proposal| { "Referer" => proposal.feature.organization.host } } + scope :accepted, -> { where(state: "accepted") } + scope :rejected, -> { where(state: "rejected") } + def author_name user_group&.name || author&.name || I18n.t("decidim.proposals.models.proposal.fields.official_proposal") end def author_avatar_url @@ -60,20 +64,25 @@ feature.settings.comments_enabled? end # Public: Overrides the `accepts_new_comments?` Commentable concern method. def accepts_new_comments? - commentable? && !feature.active_step_settings.comments_blocked + commentable? && !feature.active_step_settings.comments_blocked end # Public: Overrides the `comments_have_alignment?` Commentable concern method. def comments_have_alignment? true end # Public: Overrides the `comments_have_votes?` Commentable concern method. def comments_have_votes? true + end + + # Public: Overrides the `reported_content` Reportable concern method. + def reported_content + "<h3>#{title}</h3><p>#{body}</p>" end end end end