Skip to content
This repository has been archived by the owner on May 14, 2022. It is now read-only.

Commit

Permalink
Adding ephemera source/dspace URL fields
Browse files Browse the repository at this point in the history
  • Loading branch information
escowles committed Jul 7, 2017
1 parent 754e252 commit fe7bcfc
Show file tree
Hide file tree
Showing 11 changed files with 95 additions and 8 deletions.
8 changes: 8 additions & 0 deletions app/controllers/hyrax/ephemera_folders_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,13 @@ def new
.except("id", "barcode", "folder_number", "state") if params[:create_another]
super
end

def parent_presenter
parent_id = params[:parent_id] || presenter.box_id
@parent_presenter ||=
begin
@parent_presenter ||= show_presenter.new(search_result_document(id: parent_id), current_ability, request) if parent_id
end
end
end
end
59 changes: 56 additions & 3 deletions app/forms/hyrax/ephemera_folder_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,62 @@ module Hyrax
class EphemeraFolderForm < ::Hyrax::Forms::WorkForm
include SingleValuedForm
self.model_class = ::EphemeraFolder
self.terms = [:barcode, :folder_number, :title, :sort_title, :alternative_title, :language, :genre, :width, :height, :page_count, :box_id, :rights_statement, :series, :creator, :contributor, :publisher, :geographic_origin, :subject, :geo_subject, :description, :date_created, :member_of_collection_ids, :visibility]
self.required_fields = [:title, :barcode, :folder_number, :width, :height, :page_count, :box_id, :language, :genre, :rights_statement]
self.single_valued_fields = [:title, :sort_title, :creator, :geographic_origin, :date_created, :genre, :description, :barcode, :folder_number, :genre, :width, :height, :page_count, :rights_statement]
self.terms = [
:barcode,
:folder_number,
:title,
:sort_title,
:alternative_title,
:language,
:genre,
:width,
:height,
:page_count,
:box_id,
:rights_statement,
:series,
:creator,
:contributor,
:publisher,
:geographic_origin,
:subject,
:geo_subject,
:description,
:date_created,
:related_url,
:source,
:member_of_collection_ids,
:visibility
]
self.required_fields = [
:barcode,
:box_id,
:folder_number,
:genre,
:height,
:language,
:page_count,
:rights_statement,
:title,
:width
]
self.single_valued_fields = [
:barcode,
:creator,
:date_created,
:description,
:folder_number,
:genre,
:geographic_origin,
:height,
:page_count,
:related_url,
:rights_statement,
:sort_title,
:source,
:title,
:width
]
delegate :box_id, :project, to: :model

def rights_statement
Expand Down
4 changes: 4 additions & 0 deletions app/models/solr_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ def ephemera_project_id
Array(self[Solrizer.solr_name('ephemera_project_id', :symbol)]).first
end

def box_id
Array(self[Solrizer.solr_name('box_id', :symbol)]).first
end

def method_missing(meth_name, *args, &block)
attribute = Attribute.for(meth_name, self)
return attribute.value if attribute.valid?
Expand Down
17 changes: 15 additions & 2 deletions app/presenters/ephemera_folder_presenter.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
class EphemeraFolderPresenter < HyraxShowPresenter
include PlumAttributes
self.collection_presenter_class = DynamicShowPresenter.new
delegate :barcode, :folder_number, :box_id, :ephemera_project_id, :ephemera_project_name, to: :solr_document
delegate :barcode,
:box_id,
:description,
:ephemera_project_id,
:ephemera_project_name,
:folder_number,
to: :solr_document

def member_presenter_factory
::EfficientMemberPresenterFactory.new(solr_document, current_ability, request)
Expand Down Expand Up @@ -64,6 +70,9 @@ def local_fields
fields[:origin_place] = lookup_objects(:geographic_origin)
fields[:language] = lookup_objects(:language)
fields[:subject] = lookup_objects(:subject)
fields[:description] = description
fields[:source] = to_uri(source)
fields[:related_url] = to_uri(related_url)
end
end

Expand All @@ -77,10 +86,14 @@ def convert_to_object(id)
return id unless id.match(/^\d+/)
term = VocabularyTerm.find(id)
obj = { '@id': Rails.application.routes.url_helpers.vocabulary_term_url(id), pref_label: term.label }
obj[:exact_match] = { '@id': term.uri } if term.uri.present?
obj[:exact_match] = to_uri(term.uri) if term.uri.present?
obj
rescue
Rails.logger.warn "Error looking up #{type} #{id}"
id
end

def to_uri(value)
{ "@id": Array.wrap(value).first }
end
end
2 changes: 2 additions & 0 deletions app/schemas/ephemera_schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ class EphemeraSchema < ActiveTriples::Schema
# Subject from BasicMetadata
property :geo_subject, predicate: ::RDF::Vocab::DC.coverage
# Description from BasicMetadata
# Source from BasicMetadata
# RelatedURL form BasicMetadata
end
1 change: 1 addition & 0 deletions app/views/hyrax/base/_attributes.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<% (PlumSchema.display_fields - [:creator, :created, :date_created] + [:date_uploaded, :date_modified]).each do |display_field| %>
<%= @presenter.attribute_to_html(display_field) %>
<% end %>
<%= @presenter.attribute_to_html(:description) %>
<tr>
<th>Access Rights</th>
<td>
Expand Down
2 changes: 1 addition & 1 deletion app/views/hyrax/base/_ephemera_project.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<tr>
<td>Ephemera Project</td>
<th>Ephemera Project</th>
<td><%= link_to presenter.ephemera_project_name,
main_app.ephemera_project_path(presenter.ephemera_project_id), class: 'ephemera-project-link' %></td>
</tr>
2 changes: 1 addition & 1 deletion app/views/hyrax/base/_member_of_collections.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<tr>
<td>Member of Collections</td>
<th>Member of Collections</th>
<td>
<ul class="member_of_collections">
<% presenter.member_of_collection_presenters.each do |p| %>
Expand Down
3 changes: 3 additions & 0 deletions config/locales/blacklight.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ en:
well_formed: Well-formed
publisher: Published/Created
alternative: Alternative title
has_model: Model
related_url: DSpace URL
source: Source URL
index:
description_tesim: "Description"
keyword_tesim: "Keyword"
Expand Down
3 changes: 3 additions & 0 deletions config/locales/hyrax.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,12 @@ en:
description: 'Free-text notes about the work.'
files: ''
publisher: 'The person or group making the work available.'
related_url: ''
subject: 'Terms describing what the work is about.'
title: ''
labels:
defaults:
alternative: 'Alternative title'
description: 'Description'
related_url: 'DSpace URL'
source: 'Source URL'
2 changes: 1 addition & 1 deletion spec/controllers/hyrax/ephemera_folders_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
describe "#create" do
it "creates it as a sub-resource of a box" do
sign_in user
post :create, params: { ephemera_folder: attributes.merge(box_id: box.id, barcode: folder.barcode.first, rights_statement: "http://rightsstatements.org/vocab/NKC/1.0/") }
post :create, params: { ephemera_folder: attributes.merge(box_id: box.id, barcode: folder.barcode.first, rights_statement: "http://rightsstatements.org/vocab/NKC/1.0/"), parent_id: box.id }

expect(response).to be_redirect
id = response.headers["Location"].match(/.*\/(.*)/)[1]
Expand Down

0 comments on commit fe7bcfc

Please sign in to comment.