diff --git a/app/controllers/concerns/hydranorth/collections_controller_behavior.rb b/app/controllers/concerns/hydranorth/collections_controller_behavior.rb
index 9187c3aa..50ee0e43 100755
--- a/app/controllers/concerns/hydranorth/collections_controller_behavior.rb
+++ b/app/controllers/concerns/hydranorth/collections_controller_behavior.rb
@@ -3,30 +3,6 @@ module CollectionsControllerBehavior
extend ActiveSupport::Concern
include Sufia::CollectionsControllerBehavior
- included do
- include Blacklight::Catalog::SearchContext
- include BlacklightAdvancedSearch::ParseBasicQ
- include BlacklightAdvancedSearch::Controller
- include Hydranorth::Breadcrumbs
-
- before_filter :filter_docs_with_read_access!, except: :show
- before_filter :has_access?, except: :show
- before_filter :build_breadcrumbs, only: [:edit, :show]
-
- self.solr_search_params_logic += [:add_access_controls_to_solr_params]
-
- layout "sufia-one-column"
- end
-
- def new
- super
- form
- end
-
- def edit
- super
- form
- end
def show
if current_user.group_list == 'admin'
@@ -39,49 +15,20 @@ def show
protected
- def presenter
- @presenter ||= presenter_class.new(@collection)
- end
-
def presenter_class
- Sufia::CollectionPresenter
+ Hydranorth::CollectionPresenter
end
def collection_params
- params.require(:collection).permit(:title, :description, :members, part_of: [],
- contributor: [], creator: [], publisher: [], date_created: [], subject: [],
- language: [], rights: [], resource_type: [], identifier: [], based_near: [],
- tag: [], related_url: [])
- end
-
- def query_collection_members
- flash[:notice]=nil if flash[:notice] == "Select something first"
- query = params[:cq]
-
- #merge in the user parameters and the attach the collection query
- solr_params = (params.symbolize_keys).merge(q: query)
-
- # run the solr query to find the collections
- (@response, @member_docs) = get_search_results(solr_params)
- end
-
- def after_destroy(id)
- respond_to do |format|
- format.html { redirect_to sufia.dashboard_collections_path, notice: 'Collection was successfully deleted.' }
- format.json { render json: {id: id}, status: :destroyed, location: @collection }
- end
- end
-
- def form
- @form ||= form_class.new(@collection)
+ params.require(:collection).permit(:title, :description, :license, :members, part_of: [],
+ creator: [], date_created: [], subject: [],
+ rights: [], resource_type: [], identifier: [])
+
end
def form_class
- Sufia::Forms::CollectionEditForm
+ Hydranorth::Forms::CollectionEditForm
end
- def _prefixes
- @_prefixes ||= super + ['catalog']
- end
end
end
diff --git a/app/forms/hydranorth/forms/collection_edit_form.rb b/app/forms/hydranorth/forms/collection_edit_form.rb
new file mode 100644
index 00000000..6668c8a4
--- /dev/null
+++ b/app/forms/hydranorth/forms/collection_edit_form.rb
@@ -0,0 +1,16 @@
+module Hydranorth
+ module Forms
+ class CollectionEditForm
+ include HydraEditor::Form
+ self.model_class = ::Collection
+ self.terms = [:title, :creator, :description, :license]
+ self.required_fields = [:title, :license ]
+ # Test to see if the given field is required
+ # @param [Symbol] key a field
+ # @return [Boolean] is it required or not
+ def required?(key)
+ model_class.validators_on(key).any?{|v| v.kind_of? ActiveModel::Validations::PresenceValidator}
+ end
+ end
+ end
+end
diff --git a/app/models/collection.rb b/app/models/collection.rb
index 6bfbe4b5..050733b4 100644
--- a/app/models/collection.rb
+++ b/app/models/collection.rb
@@ -1,2 +1,3 @@
class Collection < Sufia::Collection
+ include Hydranorth::Collections::Metadata
end
diff --git a/app/models/concerns/hydranorth/collections/metadata.rb b/app/models/concerns/hydranorth/collections/metadata.rb
new file mode 100644
index 00000000..ae0740ec
--- /dev/null
+++ b/app/models/concerns/hydranorth/collections/metadata.rb
@@ -0,0 +1,10 @@
+module Hydranorth::Collections
+ module Metadata
+ extend ActiveSupport::Concern
+ included do
+ property :license, predicate: RDF::DC.license, multiple:false do |index|
+ index.as :stored_searchable
+ end
+ end
+ end
+end
diff --git a/app/presenters/hydranorth/collection_presenter.rb b/app/presenters/hydranorth/collection_presenter.rb
new file mode 100644
index 00000000..3b222ac3
--- /dev/null
+++ b/app/presenters/hydranorth/collection_presenter.rb
@@ -0,0 +1,40 @@
+module Hydranorth
+ class CollectionPresenter
+ include Hydra::Presenter
+ include ActionView::Helpers::NumberHelper
+
+ self.model_class = ::Collection
+ # Terms is the list of fields displayed by app/views/collections/_show_descriptions.html.erb
+ self.terms = [:title, :total_items, :size, :description, :creator,
+ :license, :date_created]
+
+ # Depositor and permissions are not displayed in app/views/collections/_show_descriptions.html.erb
+ # so don't include them in `terms'.
+ # delegate :depositor, :permissions, to: :model
+
+ def terms_with_values
+ terms.select { |t| self[t].present? }
+ end
+
+ def [](key)
+ case key
+ when :size
+ size
+ when :total_items
+ total_items
+ else
+ super
+ end
+ end
+
+ def size
+ number_to_human_size(model.bytes)
+ end
+
+ def total_items
+ model.members.count
+ end
+
+ end
+end
+
diff --git a/app/views/collections/_license_modal.html.erb b/app/views/collections/_license_modal.html.erb
new file mode 100644
index 00000000..7b7d537a
--- /dev/null
+++ b/app/views/collections/_license_modal.html.erb
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
Creative Commons licenses can take the following combinations, which is what a depositor sees on the page where metadata (descriptions) are entered. Via the drop-down menu, the depositor may select any of the following licenses (these are all described at "About the Licenses" on the Creative Commons site):
+
+ - Attribution 4.0 International
+ With this license you allow others to "distribute, remix, tweak, and build" on your deposited content - including for commercial purposes - provided they attribute you as the original creator.(Link to Attribution 4.0 International)
+ - Attribution-ShareAlike 4.0 International
+ With this license you allow others to "remix, tweak, and build" on your deposited content, including for commercial uses, provided they attribute you as the original creator AND incorporate the same level of licensing for the newly resulting creation. "All new works based on yours will carry the same license, so any derivatives will also allow commercial use."(Link to Attribution-ShareAlike 4.0 International)
+ - Attribution-NonCommercial 4.0 International
+ With this license you allow others to "remix, tweak, and build" on your content in non-commercial ways. While they must credit you as the original creator and while the remixed, tweaked, or expanded upon content must remain non-commercial, they do not have to apply identical license terms on the new content.(Link to Attribution-NonCommercial 4.0 International)
+ - Attribution-NoDerivs 4.0 International
+ With this license you share your work with others and allow them to download your work, provided they attribute you as the creator and refrain from changing the content in any way(Link to Attribution-NoDerivs 4.0 International)
+ - Attribution-NonCommercial-NoDerivs 4.0 International
+ With this license you share your work with others and allow them to download your work, provided they attribute you as the creator and refrain from changing the content in any way and from using it for commercial means.(Link to Attribution-NonCommercial-NoDerivs 4.0 International)
+ - Attribution-NonCommercial-ShareAlike 4.0 International
+ With this license you allow others to "remix, tweak, and build" on your content in non-commercial ways, provided they attribute you as the original creator AND incorporate the same level of licensing for the newly resulting creation. "All new works based on yours will carry the same license, so any derivatives will also allow commercial use.(Link to Attribution-NonCommercial-ShareAlike 4.0 International)
+ - Public Domain Mark 1.0
+ When content is in the public domain, it has no known copyright owner.(Link to Public Domain Mark 1.0
+ - CC0 1.0 Universal
+ With this license you are waiving your rights as copyright owner to the content you upload. This means your content may be distributed and reused without attribution, without restriction. CC0 is a license that one applies to one's own work; rarely does one apply it to another's work, unless one has the appropriate rights to do so.(Link to CC0 1.0 Universal)
+
+
+
Please note: Another license option that is listed is "All rights reserved." With this license you - as the copyright holder - reserve all rights held under copyright law, such as for distribution and creation of derivative works. This means that no one can use your content in a work - such as a presentation or article - or create derivatives from it without your permission.
+
+
+
+
+
+
diff --git a/app/views/records/edit_fields/_license.html.erb b/app/views/records/edit_fields/_license.html.erb
new file mode 100644
index 00000000..3d1eab26
--- /dev/null
+++ b/app/views/records/edit_fields/_license.html.erb
@@ -0,0 +1,3 @@
+ <%= f.input :license, as: :select_with_modal_help, collection: Sufia.config.cc_licenses,
+ input_html: { class: 'form-control', required: true }, include_blank: true %>
+ <%= render "collections/license_modal" %>
diff --git a/config/locales/sufia.en.yml b/config/locales/sufia.en.yml
index 8e0327d9..699368fb 100644
--- a/config/locales/sufia.en.yml
+++ b/config/locales/sufia.en.yml
@@ -175,10 +175,9 @@ en:
is_version_of: "Citation for previous publication"
source: "Source"
collection:
- description: "Abstract or Summary"
+ description: "Description"
subject: "Subject/Keyword"
date_created: "Date Created"
- related_url: "Related URL"
total_items: "Total Items"
size: "Size"
@@ -204,14 +203,23 @@ en:
source: "Brief information about a physical item from which this item was derived."
is_version_of: "If your item has been previously published, provide a citation"
related_url: "must be a url - example: http://www.ualberta.ca"
+ collection:
+ title: "A name for the collection to aid in identifying it. <em>This is a required field</em>."
+ description: "Free-text notes about the collection. "
+ creator_html: "The person or group responsible for the file being uploaded. Usually this is the author of the content. Personal names should be entered with the last name first, e.g. "Smith, John." <em>This is a required field</em>."
+ resource_type_html: "Pre-defined categories to describe the type of file content included in the collection, such as "article" or "dataset."."
aria_label:
generic_file:
default: "Usage information for %{title}"
based_near: "Usage information for location"
description: "Usage information for abstract or summary"
- tag: "Usage information for keyword"
+ subject: "Usage information for keyword"
rights: "Usage information for rights"
+ license: "Usage information for license"
+ collection:
+ default: "Usage information for %{title}"
+ license: "Usage information for license"
hydranorth:
dashboard:
diff --git a/spec-views/collection_form_spec.rb b/spec-views/collection_form_spec.rb
new file mode 100644
index 00000000..51e0ac78
--- /dev/null
+++ b/spec-views/collection_form_spec.rb
@@ -0,0 +1,67 @@
+require "json"
+require "selenium-webdriver"
+require "rspec"
+require "./spec-views/helper.rb"
+require "./spec-views/before.rb"
+require "./spec-views/after.rb"
+require "./spec-views/user.rb"
+include RSpec::Expectations
+
+include Before
+include After
+
+describe "Collection Creation Form" do
+
+ setup
+
+ teardown
+
+ it "form is up and new collection is created" do
+ @driver.get(@base_url + "/")
+ @driver.find_element(:link, "Login").click
+ verify { (@driver.current_url).should == @base_url+"/users/sign_in"}
+ @driver.find_element(:id, "user_email").clear
+ @driver.find_element(:id, "user_email").send_keys @properties['admin']['name']
+ @driver.find_element(:id, "user_password").clear
+ @driver.find_element(:id, "user_password").send_keys @properties['admin']['password']
+ @driver.find_element(:name, "commit").click
+ @driver.get(@base_url + "/")
+
+ @driver.find_element(:id, "dashboard_link").click
+ @driver.find_element(:id, "hydra-collection-add").click
+
+ verify { @driver.current_url.should == @base_url+"/collections/new" }
+ verify { @driver.find_element(:xpath, "//label[@for = 'collection_title']/abbr[@title = 'required']").displayed? == true }
+ title = @driver.find_element(:id, "collection_title")
+ title.clear
+ title.send_keys("Test Collection from Selenium")
+ @driver.find_element(:id, "collection_creator").send_keys @properties['user1']['name']
+ @driver.find_element(:id, "collection_description").send_keys "Test description for the test collection."
+
+ select_license = @driver.find_element(:id, "collection_license")
+ option = Selenium::WebDriver::Support::Select.new(select_license)
+ option.select_by(:text, "Public Domain Mark 1.0")
+ verify { @driver.find_element(:xpath, "//label[@for = 'collection_license']/abbr[@title = 'required']").displayed? == true }
+ @driver.find_element(:id, "create_submit").click
+
+ verify { @driver.current_url.should include @base_url + "/collections/" }
+ collection_id = @driver.current_url.match(/#{@base_url}\/collections\/(.*)$/)[1]
+ verify { (@driver.find_element(:class, "alert-success").text).should include "Collection was successfully created."}
+ verify { @driver.find_element(:css, "h1").text.should == "Test Collection from Selenium" }
+ verify { @driver.find_element(:class, "collection_description").text.should == "Test description for the test collection." }
+ verify { @driver.find_element(:xpath, "//span[@itemprop = 'creator']/span/a").text.should == @properties['user1']['name'] }
+
+ verify { @driver.find_element(:xpath, "//span[@itemprop = 'total_items']").text.should == "0" }
+ verify { @driver.find_element(:xpath, "//dt[contains(text(), 'License')]/following-sibling::dd/a").text.should == "Public Domain Mark 1.0" }
+ @driver.find_element(:link, "My Collections").click
+ verify { @driver.current_url.should == @base_url + "/dashboard/collections" }
+ collection = @driver.find_element(:id, "document_"+collection_id)
+ collection.find_element(:id, "dropdownMenu_"+collection_id).click
+ delete = "//ul[@aria-labelledby = 'dropdownMenu_"+collection_id+"']//a[@title='Delete Collection']"
+ collection.find_element(:xpath, delete).click
+ @driver.switch_to.alert.accept
+ end
+
+end
+
+