59 lines
2.8 KiB
Ruby
59 lines
2.8 KiB
Ruby
|
class DigitalArchivesController < ApplicationController
|
||
|
def index
|
||
|
if OrbitHelper.params[:item_date_low].nil?
|
||
|
@digital_content_archives = DigitalContentArchive.where(:title => /#{OrbitHelper.params[:title]}/ ,
|
||
|
:character => /#{OrbitHelper.params[:character]}/ ,
|
||
|
:location => /#{OrbitHelper.params[:location]}/,
|
||
|
:description =>/#{OrbitHelper.params[:description]}/)
|
||
|
elsif OrbitHelper.params[:item_date_low].empty? && OrbitHelper.params[:item_date_high].empty?
|
||
|
@digital_content_archives = DigitalContentArchive.where(:title => /#{OrbitHelper.params[:title]}/ ,
|
||
|
:character => /#{OrbitHelper.params[:character]}/ ,
|
||
|
:location => /#{OrbitHelper.params[:location]}/,
|
||
|
:description =>/#{OrbitHelper.params[:description]}/)
|
||
|
elsif OrbitHelper.params[:item_date_low].empty? && !OrbitHelper.params[:item_date_high].empty?
|
||
|
@digital_content_archives = DigitalContentArchive.where(:title => /#{OrbitHelper.params[:title]}/ ,
|
||
|
:character => /#{OrbitHelper.params[:character]}/ ,
|
||
|
:location => /#{OrbitHelper.params[:location]}/,
|
||
|
:description =>/#{OrbitHelper.params[:description]}/,
|
||
|
:item_date.lte => OrbitHelper.params[:item_date_high])
|
||
|
elsif !OrbitHelper.params[:item_date_low].empty? && OrbitHelper.params[:item_date_high].empty?
|
||
|
@digital_content_archives = DigitalContentArchive.where(:title => /#{OrbitHelper.params[:title]}/ ,
|
||
|
:character => /#{OrbitHelper.params[:character]}/ ,
|
||
|
:location => /#{OrbitHelper.params[:location]}/,
|
||
|
:description =>/#{OrbitHelper.params[:description]}/,
|
||
|
:item_date.gte => OrbitHelper.params[:item_date_low])
|
||
|
else
|
||
|
@digital_content_archives = DigitalContentArchive.where(:title => /#{OrbitHelper.params[:title]}/ ,
|
||
|
:character => /#{OrbitHelper.params[:character]}/ ,
|
||
|
:location => /#{OrbitHelper.params[:location]}/,
|
||
|
:description =>/#{OrbitHelper.params[:description]}/,
|
||
|
:item_date.gte => OrbitHelper.params[:item_date_low],
|
||
|
:item_date.lte => OrbitHelper.params[:item_date_high])
|
||
|
end
|
||
|
|
||
|
dcas = @digital_content_archives.collect do |dca|
|
||
|
dcafs = dca.digital_content_archive_files.collect do |file|
|
||
|
if file.choose_lang.include?(I18n.locale.to_s)
|
||
|
title = (file.file_title.blank? ? File.basename(file.file.path) : file.file_title) rescue ""
|
||
|
extension = file.file.file.extension.downcase rescue ""
|
||
|
# url = file.file.url rescue ""
|
||
|
{
|
||
|
"file-name" => title
|
||
|
}
|
||
|
end
|
||
|
end
|
||
|
{
|
||
|
"title" => (dca.title rescue ""),
|
||
|
"item-date" => (dca.item_date rescue ""),
|
||
|
"files" => dcafs
|
||
|
}
|
||
|
end
|
||
|
{
|
||
|
"digital_content_archives" => dcas
|
||
|
|
||
|
}
|
||
|
end
|
||
|
|
||
|
def show
|
||
|
end
|
||
|
end
|