60 lines
1.1 KiB
Ruby
60 lines
1.1 KiB
Ruby
# -*- encoding : utf-8 -*-
|
|
class Admin::ImageFilesController < ApplicationController
|
|
before_filter :authenticate_admin!
|
|
layout "admin"
|
|
#navigation :image_files
|
|
|
|
def index
|
|
params[:album_id] = params[:album_id] || 1
|
|
|
|
@album = Album.find(params[:album_id])
|
|
@albums = Album.all(:order => :name)
|
|
@image_files = ImageFile.all(:order => "created_at DESC", :conditions => {:album_id => @album.id})
|
|
@image_file = ImageFile.new(:album_id => @album.id)
|
|
if request.xhr?
|
|
render :layout => false
|
|
end
|
|
end
|
|
|
|
def new
|
|
end
|
|
|
|
def edit
|
|
end
|
|
|
|
def create
|
|
@image_file_create = true
|
|
@image_file = ImageFile.new(:name => params[:image_file][:name], :album_id => params[:image_file][:album_id], :file =>params[:image_file][:file][0])
|
|
|
|
if @image_file.save
|
|
|
|
else
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
def update
|
|
@image_file = ImageFile.find(params[:id])
|
|
if @image_file.update_attributes(params[:image_file])
|
|
|
|
else
|
|
|
|
end
|
|
end
|
|
|
|
def destroy
|
|
@image_file = ImageFile.find(params[:id])
|
|
@image_file.destroy
|
|
|
|
flash[:notice] = "L'image à bien été supprimée."
|
|
end
|
|
|
|
def show
|
|
@image_file = ImageFile.find(params[:id])
|
|
|
|
end
|
|
|
|
end
|