app/controllers/decidim/consultations/consultations_controller.rb in decidim-consultations-0.11.2 vs app/controllers/decidim/consultations/consultations_controller.rb in decidim-consultations-0.12.0.pre
- old
+ new
@@ -2,11 +2,11 @@
module Decidim
module Consultations
# A controller that holds the logic to show consultations in a
# public layout.
- class ConsultationsController < Decidim::ApplicationController
+ class ConsultationsController < Decidim::Consultations::ApplicationController
layout "layouts/decidim/consultation", only: :show
include NeedsConsultation
include FilterResource
include Paginable
@@ -20,31 +20,17 @@
helper Decidim::PaginateHelper
helper Decidim::IconHelper
helper Decidim::WidgetUrlsHelper
def index
- authorize! :read, Consultation
- redirect_to consultation_path(active_consultations.first) if active_consultations.count == 1
+ enforce_permission_to :read, :consultation_list
end
def show
- authorize! :read, current_consultation
+ enforce_permission_to :read, :consultation, consultation: current_consultation
end
- def finished
- authorize! :read, Consultation
- render layout: "layouts/decidim/consultation_choose"
- end
-
private
-
- def finished_consultations
- @finished_consultations ||= OrganizationConsultations.for(current_organization).finished.published
- end
-
- def active_consultations
- @active_consultations ||= OrganizationConsultations.for(current_organization).active.published
- end
def consultations
@consultations = search.results
@consultations = reorder(@consultations)
@consultations = paginate(@consultations)