61 lines
1.2 KiB
Ruby
61 lines
1.2 KiB
Ruby
# -*- encoding : utf-8 -*-
|
|
class Admin::ContactFilesController < ApplicationController
|
|
before_filter :auth_admin
|
|
|
|
|
|
layout "admin"
|
|
|
|
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)
|
|
@contact_files = DataFile.all(:order => "created_at DESC", :conditions => {:file_folder_id => @file_folder.id})
|
|
@contact_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
|
|
@contact_file_create = true
|
|
@contact_file = ContactFile.new(:name => params[:files].original_filename, :contact_id => params[:contact_id], :file =>params[:files])
|
|
|
|
if @contact_file.save
|
|
|
|
else
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
def update
|
|
@contact_file = DataFile.find(params[:id])
|
|
if @contact_file.update_attributes(params.require(:contact_file).permit!)
|
|
|
|
else
|
|
|
|
end
|
|
end
|
|
|
|
def destroy
|
|
@contact_file = DataFile.find(params[:id])
|
|
@contact_file.destroy
|
|
|
|
flash[:notice] = "Le fichier à bien été supprimée."
|
|
end
|
|
|
|
def show
|
|
@contact_file = DataFile.find(params[:id])
|
|
|
|
end
|
|
|
|
end
|