2014-03-23 00:22:25 +00:00
|
|
|
class MapsController < ApplicationController
|
2020-03-16 23:57:47 +00:00
|
|
|
before_action :get_map, only: [:show, :edit, :update, :destroy]
|
2014-03-23 00:22:25 +00:00
|
|
|
|
|
|
|
def index
|
|
|
|
@maps = Map.basic
|
|
|
|
end
|
|
|
|
|
|
|
|
def show
|
|
|
|
end
|
|
|
|
|
|
|
|
def new
|
|
|
|
@map = Map.new
|
|
|
|
raise AccessError unless @map.can_create? cuser
|
|
|
|
end
|
|
|
|
|
|
|
|
def edit
|
|
|
|
raise AccessError unless @map.can_update? cuser
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
2020-03-18 03:38:17 +00:00
|
|
|
@map = Map.new(Map.params(params, cuser))
|
2014-03-23 00:22:25 +00:00
|
|
|
raise AccessError unless @map.can_create? cuser
|
|
|
|
|
|
|
|
if @map.save
|
|
|
|
flash[:notice] = t(:maps_create)
|
|
|
|
redirect_to @map
|
|
|
|
else
|
2014-03-31 21:33:16 +00:00
|
|
|
render :new
|
2014-03-23 00:22:25 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
|
|
|
raise AccessError unless @map.can_update? cuser
|
2020-03-18 03:38:17 +00:00
|
|
|
if @map.update_attributes(Map.params(params, cuser))
|
2014-03-23 00:22:25 +00:00
|
|
|
flash[:notice] = t(:maps_update)
|
|
|
|
redirect_to @map
|
|
|
|
else
|
2014-03-31 21:33:16 +00:00
|
|
|
render :edit
|
2014-03-23 00:22:25 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
raise AccessError unless @map.can_destroy? cuser
|
|
|
|
@map.destroy
|
|
|
|
redirect_to(maps_url)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def get_map
|
|
|
|
@map = Map.find params[:id]
|
|
|
|
end
|
|
|
|
end
|