Sha256: 2b3455d583542d8f31565ff2e3bda79f80e2f77571cd8bf8bdec7f791bb7f970
Contents?: true
Size: 1.08 KB
Versions: 13
Compression:
Stored size: 1.08 KB
Contents
# frozen_string_literal: true module Decidim module Debates module Admin # This controller allows an admin to close debates class DebateClosesController < Admin::ApplicationController helper_method :debate def edit enforce_permission_to(:close, :debate, debate:) @form = form(Admin::CloseDebateForm).from_model(debate) end def update enforce_permission_to(:close, :debate, debate:) @form = form(Admin::CloseDebateForm).from_params(params) CloseDebate.call(@form) do on(:ok) do |_debate| flash[:notice] = I18n.t("debates.close.success", scope: "decidim.debates") redirect_to debates_path end on(:invalid) do flash.now[:alert] = I18n.t("debates.close.invalid", scope: "decidim.debates") render action: "edit" end end end private def debate @debate ||= Debate.where(component: current_component).find(params[:id]) end end end end end
Version data entries
13 entries across 13 versions & 1 rubygems