76 lines
1.3 KiB
Ruby
76 lines
1.3 KiB
Ruby
# -*- encoding : utf-8 -*-
|
|
|
|
class Admin::SponsorshipAnimalsController < ApplicationController
|
|
layout "admin"
|
|
before_filter :auth_admin
|
|
|
|
def index
|
|
@sponsorship_animals = SponsorshipAnimal.all
|
|
|
|
|
|
end
|
|
|
|
def show
|
|
@sponsorship_animal = SponsorshipAnimal.find(params[:id])
|
|
|
|
end
|
|
|
|
def new
|
|
|
|
|
|
@sponsorship_animal = SponsorshipAnimal.new
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
def edit
|
|
params[:lang] = params[:lang] || "fr"
|
|
|
|
@lang = LangSite.find_by_slug(params[:lang])
|
|
|
|
|
|
@sponsorship_animal = SponsorshipAnimal.find(params[:id])
|
|
end
|
|
|
|
def create
|
|
@sponsorship_animal = SponsorshipAnimal.new(params.require(:sponsorship_animal).permit!)
|
|
|
|
|
|
if @sponsorship_animal.save
|
|
redirect_to admin_sponsorship_animals_url, notice: 'La pétition a été crée.'
|
|
|
|
else
|
|
render action: "new"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
def update
|
|
@sponsorship_animal = SponsorshipAnimal.find(params[:id])
|
|
|
|
|
|
if @sponsorship_animal.update_attributes(params.require(:sponsorship_animal).permit!)
|
|
redirect_to admin_sponsorship_animals_url, notice: 'Les infos sur la pétition ont été mise à jour.'
|
|
|
|
else
|
|
render action: "edit"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
def destroy
|
|
@sponsorship_animal = SponsorshipAnimal.find(params[:id])
|
|
@sponsorship_animal.destroy
|
|
|
|
redirect_to admin_sponsorship_animals_url
|
|
|
|
end
|
|
end
|