Class: Decidim::Sortitions::Admin::ParticipatorySpaceProposals
- Inherits:
-
Query
- Object
- Query
- Decidim::Sortitions::Admin::ParticipatorySpaceProposals
- Defined in:
- app/queries/decidim/sortitions/admin/participatory_space_proposals.rb
Class Method Summary collapse
-
.for(sortition) ⇒ Object
Sugar syntax.
Instance Method Summary collapse
-
#initialize(sortition) ⇒ ParticipatorySpaceProposals
constructor
Initializes the class.
-
#query ⇒ Object
Given a participatory process retrieves its proposals.
Constructor Details
#initialize(sortition) ⇒ ParticipatorySpaceProposals
Initializes the class.
sortition - a sortition to select proposals
15 16 17 18 19 |
# File 'app/queries/decidim/sortitions/admin/participatory_space_proposals.rb', line 15 def initialize(sortition) @sortition = sortition @category = sortition.category @request_timestamp = sortition. end |
Class Method Details
.for(sortition) ⇒ Object
Sugar syntax. Retrieve all proposals for the given sortition.
8 9 10 |
# File 'app/queries/decidim/sortitions/admin/participatory_space_proposals.rb', line 8 def self.for(sortition) new(sortition).query end |
Instance Method Details
#query ⇒ Object
Given a participatory process retrieves its proposals
Returns an ActiveRecord::Relation.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/queries/decidim/sortitions/admin/participatory_space_proposals.rb', line 24 def query proposals = Decidim::Proposals::Proposal .not_withdrawn .published .not_hidden .where("decidim_proposals_proposals.created_at < ?", ) .where(component: sortition.decidim_proposals_component) proposals = proposals.where.not(id: proposals.only_status(:rejected)) return proposals.order(id: :asc) if category.nil? # categorization -> category proposals .joins(:categorization) .where(decidim_categorizations: { decidim_category_id: category.id }) .order(id: :asc) end |