# -*- encoding : utf-8 -*-
	class Admin::DataFilesController < ApplicationController
		before_filter :authenticate_admin!
	#	load_and_authorize_resource
	
	layout "admin"
	navigation :data_files
	def index
		params[:file_folder_id] = params[:file_folder_id] || 1

		@file_folder = FileFolder.find(params[:file_folder_id])
		@file_folders = FileFolder.all(:order => :name)
		@data_files = DataFile.all(:order => "created_at DESC", :conditions => {:file_folder_id => @file_folder.id})
		@data_file = DataFile.new(:file_folder_id => @file_folder.id)
		if request.xhr?
		render :layout => false
		end
	end

	def new
	end

	def edit
	end

	def create
		@data_file_create = true
		@data_file = DataFile.new(:name => params[:data_file][:name], :file_folder_id => params[:data_file][:file_folder_id], :file =>params[:data_file][:file][0])
		
		if @data_file.save

		else

		end


	end

	def update
		@data_file = DataFile.find(params[:id])
		if @data_file.update_attributes(params[:data_file])

		else
	
		end
	end

	def destroy
		@data_file = DataFile.find(params[:id])
		@data_file.destroy

		flash[:notice] = "Le fichier à bien été supprimée."
	end

	def show
		@data_file = DataFile.find(params[:id])

	end

end
