# -*- encoding : utf-8 -*-
class Admin::RegistrantsController < ApplicationController
	before_filter :authenticate_admin!
	layout "admin"
	
	navigation :registrants

	before_filter :find_registrants

	def index 

	end

	def cible
		@registrants = Registrant.all
		render :layout => false
	end
	
	def new
	
		@registrant = Registrant.new

		respond_to do |format|
	
			format.js
		end
	end

	def edit
	
		@registrant = Registrant.find(params[:id])
	end


	def create
		@registrant = Registrant.new(params[:registrant])

		respond_to do |format|
			if @registrant.save
				flash[:notice] = "Le lien à été ajouté avec succès."
				self.find_registrants
				format.js
			else
				format.html { render :action => "new" }
				format.js { render :action => "new" }
			end
		end
	end

	def update
	
		@registrant = Registrant.find(params[:id])
	
		respond_to do |format|
			if @registrant.update_attributes(params[:registrant])
			
			
				format.js
			else
			
				format.js { render :action => "edit" }
			end
		end
	end


	def destroy
		@registrant = Registrant.find(params[:id])
		@registrant.destroy

		respond_to do |format|
			format.js
		end 


	end
	
	def find_registrants
		@registrants = Registrant.all
	end
end
