Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Commit

Permalink
Merge branch 'retire-delayed-jobs'
Browse files Browse the repository at this point in the history
  • Loading branch information
louffoster committed May 31, 2022
2 parents e9efa15 + 0ff0295 commit b358ad4
Show file tree
Hide file tree
Showing 67 changed files with 266 additions and 4,007 deletions.
14 changes: 1 addition & 13 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,22 @@ gem 'ffi', '~> 1.15.0'

#gem 'passenger', '5.1.5'
gem 'figaro'
gem 'exception_notification'

gem 'turnout' # Maintence page

gem 'annotate'
gem 'mysql2'
gem 'redis' # for cache of AS session tokens
gem 'ancestry'
gem 'diffy' # to diff XML metadata changes
gem 'country-select'

# gems for APTrust submission
gem 'aws-sdk-s3', '~> 1'

gem 'delayed_job_active_record'
gem 'daemons'

# For publishing QDC
gem 'git'

gem 'whenever', :require => false # to age off job status records
gem "mini_magick"
gem 'rest-client'
gem 'prawn'
gem 'prawn-table'

gem 'jquery-rails'
gem "chosen-rails", "1.8.2"
gem "country-select", "~> 1.2"

group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
Expand Down
29 changes: 1 addition & 28 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -96,27 +96,17 @@ GEM
concurrent-ruby (1.1.5)
country-select (1.2.1)
crass (1.0.6)
daemons (1.3.1)
delayed_job (4.1.8)
activesupport (>= 3.0, < 6.1)
delayed_job_active_record (4.1.4)
activerecord (>= 3.0, < 6.1)
delayed_job (>= 3.0, < 5)
diffy (3.3.0)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
erubi (1.8.0)
exception_notification (4.4.0)
actionmailer (>= 4.0, < 7)
activesupport (>= 4.0, < 7)
execjs (2.7.0)
ffi (1.15.0)
figaro (1.1.1)
thor (~> 0.14)
formtastic (3.1.5)
actionpack (>= 3.2.13)
formtastic_i18n (0.6.0)
git (1.5.0)
globalid (0.4.2)
activesupport (>= 4.2.0)
has_scope (0.7.2)
Expand Down Expand Up @@ -167,7 +157,6 @@ GEM
mimemagic (0.3.10)
nokogiri (~> 1)
rake
mini_magick (4.9.5)
mini_mime (1.0.2)
mini_portile2 (2.4.0)
minitest (5.12.0)
Expand All @@ -176,14 +165,8 @@ GEM
nio4r (2.5.2)
nokogiri (1.10.10)
mini_portile2 (~> 2.4.0)
pdf-core (0.7.0)
polyamorous (2.3.2)
activerecord (>= 5.2.1)
prawn (2.2.2)
pdf-core (~> 0.7.0)
ttfunk (~> 1.5)
prawn-table (0.2.2)
prawn (>= 1.3.0, < 3.0.0)
pry (0.12.2)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
Expand Down Expand Up @@ -227,7 +210,6 @@ GEM
rb-fsevent (0.10.3)
rb-inotify (0.10.0)
ffi (~> 1.0)
redis (4.1.3)
responders (3.0.0)
actionpack (>= 5.0)
railties (>= 5.0)
Expand Down Expand Up @@ -257,7 +239,6 @@ GEM
thor (0.20.3)
thread_safe (0.3.6)
tilt (2.0.10)
ttfunk (1.5.1)
turnout (2.5.0)
i18n (>= 0.7, < 2)
rack (>= 1.3, < 3)
Expand Down Expand Up @@ -291,24 +272,16 @@ DEPENDENCIES
aws-sdk-s3 (~> 1)
byebug
chosen-rails (= 1.8.2)
country-select
daemons
delayed_job_active_record
country-select (~> 1.2)
diffy
exception_notification
ffi (~> 1.15.0)
figaro
git
jquery-rails
listen (>= 3.0.5, < 3.2)
mini_magick
mysql2
nokogiri (>= 1.10.8)
prawn
prawn-table
pry-rails
rails (~> 5.2.3)
redis
rest-client
sass-rails (~> 6.0)
turnout
Expand Down
4 changes: 1 addition & 3 deletions app/admin/metadata/sirsi_metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,9 @@
redirect_to "/admin/sirsi_metadata/#{params[:id]}", :notice => "Materials returned from DigiServ."
end

# Flag for publication overnight
#
member_action :publish, :method => :put do
metadata = SirsiMetadata.find(params[:id])
metadata.flag_for_publication
metadata.publish

logger.info "SirsiMetadata #{metadata.id} has been flagged for an update in the DL"
redirect_to "/admin/sirsi_metadata/#{params[:id]}", :notice => "Item flagged for publication"
Expand Down
18 changes: 18 additions & 0 deletions app/admin/metadata/xml_metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,26 @@
end
end

sidebar "Digital Library Workflow", :only => [:show], if: proc{ !current_user.viewer? && !current_user.student? } do
if xml_metadata.in_dl?
div :class => 'workflow_button' do
button_to "Publish", "/admin/xml_metadata/#{xml_metadata.id}/publish", :method => :put
end
else
"No options available. Object is not in DL."
end
end

# ACTIONS ==================================================================
#
member_action :publish, :method => :put do
metadata = XmlMetadata.find(params[:id])
metadata.publish

logger.info "XMLMetadata #{metadata.id} has been flagged for an update in the DL"
redirect_to "/admin/xml_metadata/#{params[:id]}", :notice => "Item flagged for publication"
end

controller do
def update
# create a metadata version to track this change
Expand Down
75 changes: 49 additions & 26 deletions app/admin/miscellaneous/agencies.rb
Original file line number Diff line number Diff line change
@@ -1,34 +1,57 @@
ActiveAdmin.register Agency do
menu :parent => "Miscellaneous", if: proc{ current_user.admin? || current_user.supervisor? }
config.batch_actions = false
config.per_page = [30, 50, 100, 250]
menu :parent => "Miscellaneous", if: proc{ current_user.admin? || current_user.supervisor? }
config.batch_actions = false
config.per_page = [30, 50, 100, 250]

# strong paramters handling
permit_params :name, :description, :parent_id
# strong paramters handling
permit_params :name, :description, :parent_id

config.sort_order = 'name_asc'
config.sort_order = 'name_asc'

config.clear_action_items!
filter :name_starts_with, label: "Name"

filter :name_starts_with, label: "Name"
index :id => 'agencies' do
selectable_column
column :name
column :customers do |agency|
link_to "#{agency.customers.count}", admin_customers_path(:q => {:agencies_id_eq => agency.id})
end
column :requests do |agency|
link_to "#{agency.requests.count}", admin_orders_path(:q => {:agency_id_eq => agency.id}, :scope => 'awaiting_approval')
end
column :orders do |agency|
link_to "#{agency.orders.count}", admin_orders_path(:q => {:agency_id_eq => agency.id}, :scope => 'approved')
end
column :units do |agency|
link_to "#{agency.units.count}", admin_units_path(:q => {:agency_id_eq => agency.id})
end
column :master_files do |agency|
link_to "#{agency.master_files.count}", admin_master_files_path(:q => {:agency_id_eq => agency.id})
end
column("") do |agency|
div do
link_to "Details", resource_path(agency), :class => "member_link view_link"
end
end
end

index :id => 'agencies' do
selectable_column
column :name
column :customers do |agency|
link_to "#{agency.customers.count}", admin_customers_path(:q => {:agencies_id_eq => agency.id})
show :title => proc { |agency| agency.name } do
panel "Detailed Information" do
attributes_table_for agency do
row :name
row :description
end
end
end
column :requests do |agency|
link_to "#{agency.requests.count}", admin_orders_path(:q => {:agency_id_eq => agency.id}, :scope => 'awaiting_approval')
end
column :orders do |agency|
link_to "#{agency.orders.count}", admin_orders_path(:q => {:agency_id_eq => agency.id}, :scope => 'approved')
end
column :units do |agency|
link_to "#{agency.units.count}", admin_units_path(:q => {:agency_id_eq => agency.id})
end
column :master_files do |agency|
link_to "#{agency.master_files.count}", admin_master_files_path(:q => {:agency_id_eq => agency.id})
end
end

form do |f|
f.inputs "Agency Information", :class => 'panel' do
f.input :name
f.input :description
end

f.inputs :class => 'columns-none' do
f.actions
end
end
end
85 changes: 58 additions & 27 deletions app/admin/units.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,6 @@
render "delivery_workflow", :context=>self
end

sidebar "Digital Library Workflow", :only => [:show],
if: proc{ !unit.metadata.nil? && unit.metadata.type != "ExternalMetadata" && !current_user.viewer? && !current_user.student? } do
render "dl_workflow", :context=>self
end

# ACTION ITEMS ==============================================================
#
action_item :previous, :only => :show do
Expand Down Expand Up @@ -267,27 +262,23 @@
end

member_action :download, :method => :get do
unit = Unit.find(params[:id])
att = Attachment.find(params[:attachment])
dest_dir = File.join(ARCHIVE_DIR, unit.directory, "attachments" )
dest_file = File.join(dest_dir, att.filename)
if File.exist? dest_file
send_file dest_file
else
redirect_to "/admin/units/#{params[:id]}", :notice => "Unable to find source file for attachment!"
begin
att = Attachment.find(params[:attachment])
resp = RestClient.get "#{Settings.jobs_url}/units/#{params[:id]}/attachments/#{att.filename}"
send_data(resp.body, :filename => att.filename, :disposition => 'inline')
rescue => exception
redirect_to "/admin/units/#{params[:id]}", :alert => "Unable to download attachment: #{exception}"
end
end

member_action :remove, :method => :delete do
unit = Unit.find(params[:id])
att = Attachment.find(params[:attachment])
dest_dir = File.join(ARCHIVE_DIR, unit.directory, "attachments" )
dest_file = File.join(dest_dir, att.filename)
if File.exist? dest_file
FileUtils.rm(dest_file)
begin
att = Attachment.find(params[:attachment])
RestClient.delete "#{Settings.jobs_url}/units/#{params[:id]}/attachments/#{att.filename}"
redirect_to "/admin/units/#{params[:id]}", :notice => "Attachment deleted"
rescue => exception
redirect_to "/admin/units/#{params[:id]}", :alert => "Unable to delete attachment: #{exception}"
end
att.destroy
redirect_to "/admin/units/#{params[:id]}", :notice => "Attachment deleted"
end

member_action :ocr, :method => :post do
Expand Down Expand Up @@ -379,12 +370,6 @@
end
end

member_action :publish, :method => :put do
unit = Unit.find(params[:id])
Virgo.publish(unit, Rails.logger)
redirect_to "/admin/units/#{params[:id]}", :notice => "Unit has been published to Virgo."
end

member_action :add, :method => :post do
resp = Job.submit("/units/#{params[:id]}/masterfiles/add", nil)
if resp.success?
Expand Down Expand Up @@ -419,6 +404,52 @@
render plain: resp.message, status: :internal_server_error
end
end
member_action :metadata, :method => :post do
md = Metadata.find_by(id: params[:metadata])
if md.nil?
render plain: "#{params[:metadata]} is not a valid metadata ID", status: :bad_request
return
end
if md.type == "SirsiMetadata" || (md.type == "ExternalMetadata" && md.external_system.name != "ArchivesSpace")
render plain: "#{params[:metadata]} is #{md.type}. Only XML and ArchivesSpace are supported", status: :bad_request
return
end

# update all of the selected master file metadata
mf_list = MasterFile.where(id: params[:ids])
mf_list.update_all(metadata_id: params[:metadata])

begin
# since the target metadata masterfiles list has changed, regenerate the IIIF manifest
iiif_url = "#{Settings.iiif_manifest_url}/pid/#{md.pid}?refresh=true"
Rails.logger.info "Regenerate IIIF manifest with #{iiif_url}"
resp = RestClient.get iiif_url
if resp.code.to_i != 200
Rails.logger.error "Unable to generate IIIF manifest for #{md.pid}: #{resp.body}"
else
Rails.logger.info "IIIF manifest for #{md.pid} regenerated"
end
rescue Exception => e
Rails.logger.error "Unable to generate IIIF manifest for #{md.pid}: #{e}"
end

begin
# also update the unit metadata IIIF manifest as it has changed too
unit_mf_pid = mf_list.first.unit.metadata.pid
iiif_url = "#{Settings.iiif_manifest_url}/pid/#{unit_mf_pid}?refresh=true"
Rails.logger.info "Regenerate IIIF manifest with #{iiif_url}"
resp = RestClient.get iiif_url
if resp.code.to_i != 200
Rails.logger.error "Unable to generate IIIF manifest for #{unit_mf_pid}: #{resp.body}"
else
Rails.logger.info "IIIF manifest for #{unit_mf_pid} regenerated"
end
rescue Exception => e
Rails.logger.error "Unable to generate IIIF manifest for #{unit_mf_pid}: #{e}"
end

render plain: "ok", status: :ok
end
member_action :job_status, method: :get do
job = JobStatus.find(params[:job])
render plain: job.status, status: :ok
Expand Down
Loading

0 comments on commit b358ad4

Please sign in to comment.