109 lines
1.4 KiB
Ruby
Executable File
109 lines
1.4 KiB
Ruby
Executable File
# -*- encoding : utf-8 -*-
|
|
|
|
class Admin::AbonnementsController < ApplicationController
|
|
before_filter :auth_admin
|
|
|
|
layout "admin"
|
|
|
|
|
|
before_filter :find_abonnements
|
|
|
|
|
|
def index
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def new
|
|
@abonnement = Abonnement.new()
|
|
|
|
|
|
|
|
end
|
|
|
|
def edit
|
|
@abonnement = Abonnement.find(params[:id])
|
|
end
|
|
|
|
def show
|
|
@abonnement = Abonnement.find(params[:id])
|
|
end
|
|
|
|
|
|
def create
|
|
@abonnement = Abonnement.new(params.require(:abonnement).permit!)
|
|
|
|
|
|
if @abonnement.save
|
|
|
|
find_abonnements
|
|
flash[:notice] = "La catégorie à été ajouté avec succès."
|
|
|
|
|
|
else
|
|
render :action => "new"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
def update
|
|
@abonnement = Abonnement.find(params[:id])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
if @abonnement.update_attributes(params.require(:abonnement).permit!)
|
|
|
|
|
|
|
|
flash[:notice] = "Le menu à été modifié avec succès."
|
|
|
|
if @reorder
|
|
format.js {
|
|
|
|
render :action => "update" }
|
|
else
|
|
format.js {
|
|
@abonnement = Abonnement.find(@abonnement.id)
|
|
render :action => "update_row" }
|
|
end
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
def destroy
|
|
@abonnement = Abonnement.find(params[:id])
|
|
@abonnement.destroy
|
|
find_abonnements
|
|
|
|
flash[:notice] = "La catégorie à bien été supprimée."
|
|
end
|
|
|
|
|
|
protected
|
|
|
|
def find_abonnements
|
|
|
|
@abonnements = Abonnement.order("created_at DESC").all
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|