Sha256: ff8265b4788764a814bec8105a0036f5785ef5ea1735be7726099e2933b9e4c8
Contents?: true
Size: 1.9 KB
Versions: 5
Compression:
Stored size: 1.9 KB
Contents
# frozen_string_literal: true module Decidim module Admin # Controller that allows managing areatypes to group areas class AreaTypesController < Decidim::Admin::ApplicationController layout "decidim/admin/settings" helper_method :area_types def index authorize! :index, AreaType end def new authorize! :new, AreaType @form = form(AreaTypeForm).instance end def create authorize! :new, AreaType @form = form(AreaTypeForm).from_params(params) CreateAreaType.call(@form) do on(:ok) do flash[:notice] = I18n.t("area_types.create.success", scope: "decidim.admin") redirect_to area_types_path end on(:invalid) do flash.now[:alert] = I18n.t("area_types.create.error", scope: "decidim.admin") render :new end end end def edit authorize! :update, area_type @form = form(AreaTypeForm).from_model(area_type) end def update authorize! :update, area_type @form = form(AreaTypeForm).from_params(params) UpdateAreaType.call(area_type, @form) do on(:ok) do flash[:notice] = I18n.t("area_types.update.success", scope: "decidim.admin") redirect_to area_types_path end on(:invalid) do flash.now[:alert] = I18n.t("area_types.update.error", scope: "decidim.admin") render :edit end end end def destroy authorize! :destroy, area_type area_type.destroy! flash[:notice] = I18n.t("area_types.destroy.success", scope: "decidim.admin") redirect_to area_types_path end private def area_type @area_type ||= area_types.find(params[:id]) end def area_types current_organization.area_types end end end end
Version data entries
5 entries across 5 versions & 1 rubygems