# -*- encoding : utf-8 -*-

class Admin::ActualitiesController < ApplicationController
	before_filter :authenticate_admin!

	layout "admin"

	before_filter :find_actualities


	def index 

	end
	

	def cible
		@actualities = Actuality.all

		render :layout => false
	end

	
	def new
		@actuality = Actuality.new

	end

	def edit
		@actuality = Actuality.find(params[:id])
		render :layout => false
	end


	def create
		@actuality = Actuality.new(params[:actuality])


		if @actuality.save
			flash[:notice] = "L'événement à été ajouté avec succès."
		
			self.find_actualities #reload actualities to show new actualities in the list sort by date.

		else
			render :action => "new" 
		
		end
	
	end
	

	def update
		@actuality = Actuality.find(params[:id])

		if @actuality.update_attributes(params[:actuality])
			flash[:notice] = "L'événement à été modifié avec succès."
		else
			render :action => "edit" 
			
		end

	end


	def destroy
		@actuality = Actuality.find(params[:id])
		@actuality.destroy

	end
	
	
	protected
	
	def find_actualities
		@actualities = Actuality.all
		
	end
end
