# frozen_string_literal: true module Decidim module Admin # Base controller that can be inherited by other spaces to publish and unpublish the Space # class SpacePublicationsController < Decidim::Assemblies::Admin::ApplicationController def create enforce_permission_to_publish publish_command.call(current_assembly, current_user) do on(:ok) do flash[:notice] = I18n.t("create.success", scope: i18n_scope) end on(:invalid) do flash.now[:alert] = I18n.t("create.error", scope: i18n_scope) end redirect_back(fallback_location: assemblies_path) end end def destroy enforce_permission_to_publish unpublish_command.call(current_assembly, current_user) do on(:ok) do flash[:notice] = I18n.t("destroy.success", scope: i18n_scope) end on(:invalid) do flash.now[:alert] = I18n.t("destroy.error", scope: i18n_scope) end redirect_back(fallback_location: assemblies_path) end end private def current_participatory_space raise "Not implemented" end def enforce_permission_to_publish raise "Not implemented" end def publish_command raise "Not implemented" end def unpublish_command raise "Not implemented" end def i18n_scope raise "Not implemented" end end end end