Class: Decidim::Initiatives::Admin::InitiativesTypesController
- Inherits:
-
ApplicationController
- Object
- DecidimController
- Admin::ApplicationController
- ApplicationController
- Decidim::Initiatives::Admin::InitiativesTypesController
- Defined in:
- decidim-initiatives/app/controllers/decidim/initiatives/admin/initiatives_types_controller.rb
Overview
Controller used to manage the available initiative types for the current organization.
Instance Method Summary collapse
-
#create ⇒ Object
POST /admin/initiatives_types.
-
#destroy ⇒ Object
DELETE /admin/initiatives_types/:id.
-
#edit ⇒ Object
GET /admin/initiatives_types/:id/edit.
-
#index ⇒ Object
GET /admin/initiatives_types.
-
#new ⇒ Object
GET /admin/initiatives_types/new.
-
#update ⇒ Object
PUT /admin/initiatives_types/:id.
Methods inherited from ApplicationController
#permission_class_chain, #permissions_context
Methods inherited from Admin::ApplicationController
#permission_class_chain, #permission_scope, #user_has_no_permission_path, #user_not_authorized_path
Methods included from HttpCachingDisabler
Methods included from NeedsSnippets
Methods included from NeedsOrganization
enhance_controller, extended, included
Instance Method Details
#create ⇒ Object
POST /admin/initiatives_types
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'decidim-initiatives/app/controllers/decidim/initiatives/admin/initiatives_types_controller.rb', line 26 def create :create, :initiative_type @form = initiative_type_form.from_params(params) CreateInitiativeType.call(@form, current_user) do on(:ok) do |initiative_type| flash[:notice] = I18n.t("decidim.initiatives.admin.initiatives_types.create.success") redirect_to edit_initiatives_type_path(initiative_type) end on(:invalid) do flash.now[:alert] = I18n.t("decidim.initiatives.admin.initiatives_types.create.error") render :new end end end |
#destroy ⇒ Object
DELETE /admin/initiatives_types/:id
72 73 74 75 76 77 78 79 80 81 82 |
# File 'decidim-initiatives/app/controllers/decidim/initiatives/admin/initiatives_types_controller.rb', line 72 def destroy :destroy, :initiative_type, initiative_type: current_initiative_type Decidim.traceability.perform_action!("delete", current_initiative_type, current_user) do current_initiative_type.destroy! end redirect_to initiatives_types_path, flash: { notice: I18n.t("decidim.initiatives.admin.initiatives_types.destroy.success") } end |
#edit ⇒ Object
GET /admin/initiatives_types/:id/edit
44 45 46 47 48 49 |
# File 'decidim-initiatives/app/controllers/decidim/initiatives/admin/initiatives_types_controller.rb', line 44 def edit :edit, :initiative_type, initiative_type: current_initiative_type @form = initiative_type_form .from_model(current_initiative_type, initiative_type: current_initiative_type) end |
#index ⇒ Object
GET /admin/initiatives_types
13 14 15 16 17 |
# File 'decidim-initiatives/app/controllers/decidim/initiatives/admin/initiatives_types_controller.rb', line 13 def index :index, :initiative_type @initiatives_types = InitiativeTypes.for(current_organization) end |
#new ⇒ Object
GET /admin/initiatives_types/new
20 21 22 23 |
# File 'decidim-initiatives/app/controllers/decidim/initiatives/admin/initiatives_types_controller.rb', line 20 def new :create, :initiative_type @form = initiative_type_form.instance end |
#update ⇒ Object
PUT /admin/initiatives_types/:id
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'decidim-initiatives/app/controllers/decidim/initiatives/admin/initiatives_types_controller.rb', line 52 def update :update, :initiative_type, initiative_type: current_initiative_type @form = initiative_type_form .from_params(params, initiative_type: current_initiative_type) UpdateInitiativeType.call(current_initiative_type, @form, current_user) do on(:ok) do flash[:notice] = I18n.t("decidim.initiatives.admin.initiatives_types.update.success") redirect_to edit_initiatives_type_path(current_initiative_type) end on(:invalid) do flash.now[:alert] = I18n.t("decidim.initiatives.admin.initiatives_types.update.error") render :edit end end end |