Class: Decidim::Geo::Admin::ShapefilesController

Inherits:
Decidim::Geo::ApplicationController show all
Defined in:
app/controllers/decidim/geo/admin/shapefiles_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/controllers/decidim/geo/admin/shapefiles_controller.rb', line 20

def create
  enforce_permission_to :create, :shapefile
  @form = form(Decidim::Geo::Admin::ShapefileForm).from_params(params)

  return Admin::CreateShapefile.call(@form) do
    on(:invalid) do |message|
      flash.now[:alert] = message || @form.errors.full_messages.join(',') || "Can not upload this shapefile"
      render action: "new"
    end

    on(:ok) do
      flash[:notice] = I18n.t("shapefiles.actions.create.success", scope: "decidim.geo.admin")
      redirect_to shapefiles_path
    end

  
  end
end

#indexObject



10
11
12
13
# File 'app/controllers/decidim/geo/admin/shapefiles_controller.rb', line 10

def index
  #enforce_permission_to :list
  @shapefiles = Decidim::Geo::Shapefile.all
end

#newObject



15
16
17
18
# File 'app/controllers/decidim/geo/admin/shapefiles_controller.rb', line 15

def new
  enforce_permission_to :new, :shapefile
  @form = Decidim::Geo::Admin::ShapefileForm.new
end