Note that in the budgets wizard test we now create district with no associated geozone, so the text "all city" will appear in the districts table too, meaning we can't use `within "section", text: "All city" do` anymore since it would result in an ambiguous match. Co-Authored-By: Julian Herrero <microweb10@gmail.com> Co-Authored-By: Javi Martín <javim@elretirao.net>
53 lines
1.1 KiB
Ruby
53 lines
1.1 KiB
Ruby
class Admin::GeozonesController < Admin::BaseController
|
|
respond_to :html
|
|
|
|
load_and_authorize_resource
|
|
|
|
def index
|
|
@geozones = Geozone.all.order(Arel.sql("LOWER(name)"))
|
|
end
|
|
|
|
def new
|
|
end
|
|
|
|
def edit
|
|
end
|
|
|
|
def create
|
|
@geozone = Geozone.new(geozone_params)
|
|
|
|
if @geozone.save
|
|
redirect_to admin_geozones_path, notice: t("admin.geozones.create.notice")
|
|
else
|
|
render :new
|
|
end
|
|
end
|
|
|
|
def update
|
|
if @geozone.update(geozone_params)
|
|
redirect_to admin_geozones_path, notice: t("admin.geozones.update.notice")
|
|
else
|
|
render :edit
|
|
end
|
|
end
|
|
|
|
def destroy
|
|
if @geozone.safe_to_destroy?
|
|
@geozone.destroy!
|
|
redirect_to admin_geozones_path, notice: t("admin.geozones.delete.success")
|
|
else
|
|
redirect_to admin_geozones_path, flash: { error: t("admin.geozones.delete.error") }
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def geozone_params
|
|
params.require(:geozone).permit(allowed_params)
|
|
end
|
|
|
|
def allowed_params
|
|
[:name, :external_code, :census_code, :html_map_coordinates, :geojson, :color]
|
|
end
|
|
end
|