Sha256: 946e9694da6756b2c2ddf7b7bb21afbebb4c599931abcf007c77a907974b9da2
Contents?: true
Size: 2 KB
Versions: 6
Compression:
Stored size: 2 KB
Contents
# frozen_string_literal: true module Decidim module Debates module Admin # This controller allows an admin to manage debates from a Participatory Space class DebatesController < Admin::ApplicationController helper_method :debates def new @form = form(Decidim::Debates::Admin::DebateForm).instance end def create @form = form(Decidim::Debates::Admin::DebateForm).from_params(params, current_feature: current_feature) CreateDebate.call(@form) do on(:ok) do flash[:notice] = I18n.t("debates.create.success", scope: "decidim.debates.admin") redirect_to debates_path end on(:invalid) do flash.now[:alert] = I18n.t("debates.create.invalid", scope: "decidim.debates.admin") render action: "new" end end end def edit authorize! :edit, debate @form = form(DebateForm).from_model(debate) end def update authorize! :edit, debate @form = form(DebateForm).from_params(params, current_feature: current_feature) UpdateDebate.call(@form, debate) do on(:ok) do flash[:notice] = I18n.t("debates.update.success", scope: "decidim.debates.admin") redirect_to debates_path end on(:invalid) do flash.now[:alert] = I18n.t("debates.update.invalid", scope: "decidim.debates.admin") render action: "edit" end end end def destroy authorize! :destroy, debate debate.destroy! flash[:notice] = I18n.t("debates.destroy.success", scope: "decidim.debates.admin") redirect_to debates_path end private def debates @debates ||= Debate.where(feature: current_feature) end def debate @debate ||= debates.find(params[:id]) end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems