This repository has been archived by the owner on Jan 5, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #156 from ualbertalib/collection-form
Modified the Collection form to reflect the HN data dictionary
- Loading branch information
Showing
9 changed files
with
193 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
class Collection < Sufia::Collection | ||
include Hydranorth::Collections::Metadata | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<div class="modal-div"> | ||
<!-- Modal --> | ||
<div class="modal fade" id="licenseModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> | ||
<div class="modal-dialog"> | ||
<div class="modal-content"> | ||
<div class="modal-header"> | ||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button> | ||
<h2 id="licenseModallLabel"><%= t('sufia.product_name') %> License Descriptions</h2> | ||
</div> | ||
<div class="modal-body"> | ||
<p>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): | ||
</p> <ul> | ||
<li><b>Attribution 4.0 International</b><br/> | ||
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.<a href="http://creativecommons.org/licenses/by/4.0/" target="_blank">(Link to Attribution 4.0 International)</a></li> | ||
<li><b>Attribution-ShareAlike 4.0 International</b> <br/> | ||
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."<a href="http://creativecommons.org/licenses/by-sa/4.0/" target="_blank">(Link to Attribution-ShareAlike 4.0 International)</a></li> | ||
<li><b>Attribution-NonCommercial 4.0 International</b><br/> | ||
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.<a href="http://creativecommons.org/licenses/by-nc/4.0/" target="_blank">(Link to Attribution-NonCommercial 4.0 International)</a></li> | ||
<li><b>Attribution-NoDerivs 4.0 International</b><br/> | ||
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<a href="http://creativecommons.org/licenses/by-nd/4.0/" target="_blank">(Link to Attribution-NoDerivs 4.0 International)</a> </li> | ||
<li><b>Attribution-NonCommercial-NoDerivs 4.0 International</b><br/> | ||
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.<a href="http://creativecommons.org/licenses/by-nc-nd/4.0/" target="_blank">(Link to Attribution-NonCommercial-NoDerivs 4.0 International)</a></li> | ||
<li><b>Attribution-NonCommercial-ShareAlike 4.0 International</b><br/> | ||
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.<a href="http://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">(Link to Attribution-NonCommercial-ShareAlike 4.0 International)</a> </li> | ||
<li><b>Public Domain Mark 1.0 </b><br/> | ||
When content is in the public domain, it has no known copyright owner.<a href="http://creativecommons.org/publicdomain/mark/1.0/" target="_blank">(Link to Public Domain Mark 1.0</a> </li> | ||
<li><b>CC0 1.0 Universal </b><br/> | ||
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.<a href="https://creativecommons.org/publicdomain/zero/1.0/" target="_blank">(Link to CC0 1.0 Universal)</a></li> | ||
</ul> | ||
</p> | ||
<p> Please note: Another license option that is listed is <b>"All rights reserved."</b> 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.</p> | ||
</div> | ||
<div class="modal-footer"> | ||
<button class="btn btn-primary" data-dismiss="modal">Close</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
||
|