86 lines
1.9 KiB
Ruby
86 lines
1.9 KiB
Ruby
# -*- encoding : utf-8 -*-
|
|
|
|
class Admin::SpecificMapItemsController < ApplicationController
|
|
layout "admin"
|
|
before_filter :auth_admin
|
|
|
|
def index
|
|
per_page = (params[:per_page] and params[:per_page] != "") ? params[:per_page] : 50
|
|
page = (params[:page] and params[:page] != "") ? params[:page] : 1
|
|
|
|
|
|
|
|
|
|
@specific_map_items = SpecificMapItem.page(page).per(per_page)
|
|
|
|
|
|
end
|
|
|
|
def show
|
|
@specific_map_item = SpecificMapItem.find(params[:id])
|
|
|
|
end
|
|
|
|
def new
|
|
@specific_map = SpecificMap.find(params[:specific_map_id])
|
|
|
|
@specific_map_item = SpecificMapItem.new(:specific_map_id => @specific_map.id)
|
|
|
|
|
|
end
|
|
|
|
|
|
def geoloc
|
|
@specific_map = SpecificMap.find(params[:specific_map_id])
|
|
@specific_map_item = SpecificMapItem.find(params[:id])
|
|
|
|
@specific_map_item.geolocalise
|
|
@specific_map_item.save
|
|
end
|
|
def edit
|
|
@specific_map = SpecificMap.find(params[:specific_map_id])
|
|
|
|
@specific_map_item = SpecificMapItem.find(params[:id])
|
|
end
|
|
|
|
def create
|
|
@specific_map = SpecificMap.find(params[:specific_map_id])
|
|
@specific_map_item = SpecificMapItem.new(params.require(:specific_map_item).permit!)
|
|
|
|
|
|
if @specific_map_item.save
|
|
redirect_to admin_specific_map_url(@specific_map), notice: 'La pétition a été crée.'
|
|
|
|
else
|
|
render action: "new"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
def update
|
|
@specific_map = SpecificMap.find(params[:specific_map_id])
|
|
@specific_map_item = SpecificMapItem.find(params[:id])
|
|
|
|
|
|
if @specific_map_item.update_attributes(params.require(:specific_map_item).permit!)
|
|
#redirect_to admin_specific_map_items_url, notice: 'Les infos sur la pétition ont été mise à jour.'
|
|
|
|
else
|
|
render action: "edit"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
def destroy
|
|
@specific_map_item = SpecificMapItem.find(params[:id])
|
|
@specific_map_item.destroy
|
|
|
|
#redirect_to admin_specific_map_items_url
|
|
|
|
end
|
|
end
|