Sha256: d61518d432aa1d521ecb36443e5263dfb8205e8e8d2e6640a052ec93cef56ed7
Contents?: true
Size: 1.67 KB
Versions: 3
Compression:
Stored size: 1.67 KB
Contents
# frozen_string_literal: true module Decidim module Budgets # Exposes the project resource so users can view them class ProjectsController < Decidim::Budgets::ApplicationController include FilterResource include NeedsCurrentOrder include Decidim::Budgets::Orderable helper_method :projects, :project, :budget, :all_geocoded_projects def index raise ActionController::RoutingError, "Not Found" unless budget end def show raise ActionController::RoutingError, "Not Found" unless budget raise ActionController::RoutingError, "Not Found" unless project end private def budget @budget ||= Budget.where(component: current_component).includes(:projects).find_by(id: params[:budget_id]) end def projects return @projects if @projects @projects = reorder(search.result) @projects = @projects.page(params[:page]).per(current_component.settings.projects_per_page) end def all_geocoded_projects @all_geocoded_projects ||= projects.geocoded end def project @project ||= Project.find_by(id: params[:id]) end def search_collection Project.where(budget: budget).includes([:scope, :component, :attachments, :category]) end def default_filter_params { search_text_cont: "", with_any_status: default_filter_status_params, with_any_scope: default_filter_scope_params, with_any_category: default_filter_category_params } end def default_filter_status_params voting_finished? ? %w(selected) : %w(all) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems