94 lines
1.1 KiB
Ruby
94 lines
1.1 KiB
Ruby
# -*- encoding : utf-8 -*-
|
|
|
|
class Admin::ProjetsController < ApplicationController
|
|
|
|
before_filter :auth_admin
|
|
|
|
layout "admin"
|
|
|
|
|
|
def index
|
|
@projets = Projet.all
|
|
|
|
@projets = @projets.page(params[:page]).per(15)
|
|
end
|
|
|
|
|
|
|
|
def new
|
|
|
|
@projet = Projet.new()
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
def edit
|
|
|
|
|
|
|
|
@projet = Projet.find(params[:id])
|
|
|
|
|
|
end
|
|
|
|
|
|
def show
|
|
|
|
|
|
@projet = Projet.find(params[:id])
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
def create
|
|
|
|
@projet = Projet.new(params.require(:projet).permit!)
|
|
|
|
|
|
if @projet.save
|
|
flash[:notice] = "Le projet à été ajouté avec succès."
|
|
redirect_to :action => :index
|
|
|
|
else
|
|
render :action => "new"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
def update
|
|
|
|
@projet = Projet.find(params[:id])
|
|
|
|
|
|
|
|
if @projet.update_attributes(params.require(:projet).permit!)
|
|
flash[:notice] = "L'projet à été modifié avec succès."
|
|
redirect_to :action => :index
|
|
else
|
|
render :action => "edit"
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
def destroy
|
|
|
|
@projet = Projet.find(params[:id])
|
|
@projet.destroy
|
|
redirect_to :action => :index
|
|
end
|
|
|
|
|
|
end
|