Class: Decidim::Assemblies::Admin::AssembliesController
- Inherits:
-
ApplicationController
- Object
- Decidim::Admin::ApplicationController
- ApplicationController
- Decidim::Assemblies::Admin::AssembliesController
- Includes:
- Decidim::Admin::ParticipatorySpaceAdminBreadcrumb, Filterable
- Defined in:
- app/controllers/decidim/assemblies/admin/assemblies_controller.rb
Overview
Controller that allows managing assemblies.
Instance Method Summary collapse
Instance Method Details
#copy ⇒ Object
68 69 70 |
# File 'app/controllers/decidim/assemblies/admin/assemblies_controller.rb', line 68 def copy :create, :assembly, assembly: collection.find_by(id: params[:parent_id]) end |
#create ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/controllers/decidim/assemblies/admin/assemblies_controller.rb', line 25 def create :create, :assembly, assembly: parent_assembly @form = form(AssemblyForm).from_params(params) CreateAssembly.call(@form) do on(:ok) do |assembly| flash[:notice] = I18n.t("assemblies.create.success", scope: "decidim.admin") redirect_to assemblies_path(q: { parent_id_eq: assembly.parent_id }) end on(:invalid) do flash.now[:alert] = I18n.t("assemblies.create.error", scope: "decidim.admin") render :new end end end |
#edit ⇒ Object
42 43 44 45 46 |
# File 'app/controllers/decidim/assemblies/admin/assemblies_controller.rb', line 42 def edit :update, :assembly, assembly: current_assembly @form = form(AssemblyForm).from_model(current_assembly) render layout: "decidim/admin/assembly" end |
#index ⇒ Object
14 15 16 17 |
# File 'app/controllers/decidim/assemblies/admin/assemblies_controller.rb', line 14 def index :read, :assembly_list @assemblies = filtered_collection end |
#new ⇒ Object
19 20 21 22 23 |
# File 'app/controllers/decidim/assemblies/admin/assemblies_controller.rb', line 19 def new :create, :assembly, assembly: parent_assembly @form = form(AssemblyForm).instance @form.parent_id = params[:parent_id] end |
#update ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'app/controllers/decidim/assemblies/admin/assemblies_controller.rb', line 48 def update :update, :assembly, assembly: current_assembly @form = form(AssemblyForm).from_params( assembly_params, assembly_id: current_assembly.id ) UpdateAssembly.call(@form, current_assembly) do on(:ok) do |assembly| flash[:notice] = I18n.t("assemblies.update.success", scope: "decidim.admin") redirect_to edit_assembly_path(assembly) end on(:invalid) do flash.now[:alert] = I18n.t("assemblies.update.error", scope: "decidim.admin") render :edit, layout: "decidim/admin/assembly" end end end |