Skip to content

Commit

Permalink
Merge pull request #81 from NEU-DSG/pr-party
Browse files Browse the repository at this point in the history
PR party
  • Loading branch information
amclark42 authored Jan 30, 2023
2 parents 51b17ad + 4caf37e commit ede87c8
Show file tree
Hide file tree
Showing 61 changed files with 647 additions and 854 deletions.
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ gem 'resque', :require => 'resque/server'
# Use Nest because some inherited config uses Nest
gem 'nest'

gem 'aws-sdk-s3', require: false

gem 'discard', '~> 1.2'

# Use thor for command line tasks
# gem 'thor', '1.0.1'

Expand Down
29 changes: 21 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,22 @@ GEM
arel (9.0.0)
autoprefixer-rails (9.7.6)
execjs
aws-eventstream (1.1.0)
aws-partitions (1.341.0)
aws-sdk-core (3.103.0)
aws-eventstream (~> 1, >= 1.0.2)
aws-partitions (~> 1, >= 1.239.0)
aws-sigv4 (~> 1.1)
jmespath (~> 1.0)
aws-sdk-kms (1.36.0)
aws-sdk-core (~> 3, >= 3.99.0)
aws-sigv4 (~> 1.1)
aws-sdk-s3 (1.74.0)
aws-sdk-core (~> 3, >= 3.102.1)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.1)
aws-sigv4 (1.2.1)
aws-eventstream (~> 1, >= 1.0.2)
bcrypt (3.1.13)
blacklight (6.23.0)
bootstrap-sass (~> 3.2)
Expand Down Expand Up @@ -157,6 +173,8 @@ GEM
devise-guests (0.7.0)
devise
diff-lcs (1.3)
discard (1.2.0)
activerecord (>= 4.2, < 7)
docile (1.3.2)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
Expand Down Expand Up @@ -287,6 +305,7 @@ GEM
i18n
logger
rubyzip
jmespath (1.4.0)
jquery-rails (4.4.0)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
Expand Down Expand Up @@ -383,7 +402,6 @@ GEM
passenger (6.0.4)
rack
rake (>= 0.8.1)
pr_geohash (1.0.0)
pry (0.13.1)
coderay (~> 1.1)
method_source (~> 1.0)
Expand Down Expand Up @@ -552,12 +570,6 @@ GEM
activesupport
mods (~> 2.2)
stomp (1.4.9)
sunspot (2.5.0)
pr_geohash (~> 1.0)
rsolr (>= 1.1.1, < 3)
sunspot_rails (2.5.0)
rails (>= 3)
sunspot (= 2.5.0)
sunspot_solr (2.5.0)
sxp (1.1.0)
rdf (~> 3.1)
Expand Down Expand Up @@ -597,6 +609,7 @@ PLATFORMS
DEPENDENCIES
active-fedora (~> 11.0)
active_fedora-datastreams
aws-sdk-s3
blacklight
blacklight-gallery
bootstrap-sass (= 3.3.4.1)
Expand All @@ -611,6 +624,7 @@ DEPENDENCIES
coffee-rails (~> 5.0.0)
devise
devise-guests (~> 0.3)
discard (~> 1.2)
exception_notification
factory_bot_rails
figaro
Expand Down Expand Up @@ -646,7 +660,6 @@ DEPENDENCIES
simplecov-json
simplecov-rcov
sprockets (~> 3.7.2)
sunspot_rails
sunspot_solr
therubyracer
turbolinks
Expand Down
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,27 @@ To run the job that reruns all of the core_files through the reading interface b

bundle exec cap production resque:restart



To modify the main menu
- open the menu.en.yml file and modify/reorder/add/delete values where necessary


## Development

To get started developing TAPAS, first install the required software:

- Ruby 2.6.3
- Rails 5.2
- MySQL 5.x

Then follow these steps:

0. Clone this repository and cd to the repository directory
1. Create a mysql database and import the TAPAS sql file
2. Configure application.yml file with correct parameters
4. cd to project directory && `bundle install`
5. Run `rails s` to start the application

#### Notes for OSX

- installing nokogiri on OSX: `$ gem install nokogiri -- --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/libxml2 --use-system-libraries`
- configuring bundle install with correct openssl from brew:
Expand Down
1 change: 0 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require File.expand_path('../config/application', __FILE__)
require 'resque/tasks'

TapasRails::Application.load_tasks
4 changes: 1 addition & 3 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@
//= require jquery-ui/widgets/resizable

//
// Required by Blacklight
//= require blacklight/blacklight
//= require bootstrap/button
//= require bootstrap/tooltip
//= require bootstrap/popover
//= require bootstrap/tab
//= require bootstrap/carousel
//= require activestorage
//= require plugins
//= require tapasApp
//= require forem
//= require jquery.nestable
4 changes: 4 additions & 0 deletions app/assets/javascripts/tapasApp.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ $(document).ready ->
target: $('span.collection:not(.to-remove)')
titleText: 'Remove collection'

# TODO: (charles) possible quick and dirty way to autocomplete users when creating a record
# $('.core_file_authors').autocomplete
# source: $('#core_file_authors').data('autocomplete-source')

return


Expand Down
122 changes: 46 additions & 76 deletions app/controllers/collections_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
class CollectionsController < CatalogController
include ApiAccessible
include ControllerHelper

self.copy_blacklight_config_from(CatalogController)

Expand All @@ -18,7 +17,6 @@ def upsert
pretty_json(202) and return
end

#This method displays all the collections present
def index
@page_title = "All Collections"
# self.search_params_logic += [:collections_filter]
Expand All @@ -30,106 +28,78 @@ def index
end
end

#This method is the helper method for index. It basically gets the collections
# using solr queries
def collections_filter(solr_parameters, user_parameters)
model_type = RSolr.solr_escape "info:fedora/afmodel:Collection"
query = "has_model_ssim:\"#{model_type}\""
solr_parameters[:fq] ||= []
solr_parameters[:fq] << query
end

#This method is used to display various attributes of a collection
def show
@collection = Collection.find(params[:id])
@page_title = @collection.title
end

#This method is used to create a new collection
def new
@page_title = "Create New Collection"
model_type = RSolr.solr_escape "info:fedora/afmodel:Community"
query = "has_model_ssim:\"#{model_type}\" && (depositor_tesim:\"#{current_user.id.to_s}\" OR project_admins_ssim:\"#{current_user.id.to_s}\" OR project_editors_ssim:\"#{current_user.id.to_s}\")"
count = ActiveFedora::SolrService.count(query)
results = ActiveFedora::SolrService.query(query, fl: 'did_ssim, title_info_title_ssi, id', rows: count)
# count = ActiveFedora::SolrService.count("has_model_ssim:\"#{model_type}\"")
# results = ActiveFedora::SolrService.query("has_model_ssim:\"#{model_type}\"", fl: 'did_ssim, title_info_title_ssi, id', rows: count)

@communities =[]
results.each do |res|
if !res['title_info_title_ssi'].blank? #&& !res['did_ssim'].blank? && res['did_ssim'].count > 0
@communities << [res['title_info_title_ssi'], res['id']] #,res['did_ssim'][0]]
end
end
@collection = Collection.new(:mass_permissions=>"public")
@communities = Community.joins(:community_members).where(community_members: { user_id: current_user.id, member_type: ["editor", "admin"] })
@collection = Collection.new(community: @community)
end

#This method contains the actual logic for creating a new collection
def create
# @collection = Collection.new
puts params
community = Community.find(params[:community]) if params[:community]
params[:collection].delete("community")
@collection = Collection.new(params[:collection])
@collection.depositor = current_user.id.to_s
@collection.did = @collection.pid
@collection.mass_permissions = params[:mass_permissions]
@collection.save! #object must be saved before community can be assigned
@collection.community = community if community
@collection = Collection.new(collection_params)
@collection.depositor = current_user
@collection.save!

if (params[:thumbnail])
params[:thumbnail] = create_temp_file(params[:thumbnail])
@collection.add_thumbnail(:filepath => params[:thumbnail])
@collection.save!
end
# if (params[:thumbnail])
# params[:thumbnail] = create_temp_file(params[:thumbnail])
# @collection.add_thumbnail(:filepath => params[:thumbnail])
# @collection.save!
# end
# can this be used instead of individually spelling out the methods?
# TapasRails::Application::Queue.push TapasObjectUpsertJob.new params

redirect_to @collection and return
end

#This method is used to edit a particular collection
def destroy
collection = Collection.find(params[:id])
community = collection.community

collection.discard!

redirect_to community
end

def edit
model_type = RSolr.solr_escape "info:fedora/afmodel:Community"
count = ActiveFedora::SolrService.count("has_model_ssim:\"#{model_type}\"")
results = ActiveFedora::SolrService.query("has_model_ssim:\"#{model_type}\"", fl: 'id, title_info_title_ssi', rows: count)
@communities =[]
results.each do |res|
if !res['title_info_title_ssi'].blank? && !res['id'].blank?
@communities << [res['title_info_title_ssi'],res['id']]
end
end
@collection = Collection.find(params[:id])
@communities = Community.accessible_by(current_ability)
@page_title = "Edit #{@collection.title}"
end

#This method contains the actual logic for editing a particular collection
def update
community = Community.find(params[:community]) if params[:community]
params[:collection].delete("community")
@collection = Collection.find(params[:id])
# @core_files = CoreFile.find_by_did(params[:id])
if params[:collection][:remove_thumbnail] == "1"
params[:collection].delete :thumbnail
@collection.thumbnails = []
@collection.save!
end
params[:collection].delete :remove_thumbnail
@collection.update_attributes(params[:collection])
@collection.mass_permissions = params[:mass_permissions]
@collection.save!
@collection.community = community if community
@collection.save!

if (params[:thumbnail])
params[:thumbnail] = create_temp_file(params[:thumbnail])
@collection.add_thumbnail(:filepath => params[:thumbnail])
@collection.save!
end
# can this be used instead of individually spelling out the methods?
# TapasRails::Application::Queue.push TapasObjectUpsertJob.new params
@collection.update(collection_params)

redirect_to @collection and return
end

protected

def can_edit?
collection = Collection.find(params[:id])
can? :manage, collection
end

def can_read?
collection = Collection.find(params[:id])
can? :read, collection
end

private

def collection_params
params
.require(:collection)
.permit(
:community_id,
:description,
:is_public,
:title,
thumbnails: []
)
end
end
Loading

0 comments on commit ede87c8

Please sign in to comment.