Skip to content

Commit

Permalink
Merge branch '4.3-devel' of https://github.com/rism-ch/muscat into 4.…
Browse files Browse the repository at this point in the history
…3-devel

* '4.3-devel' of https://github.com/rism-ch/muscat:
  Updated rspec readme
  Switch from poltergeist to headless chrome
  one function for click an keypress
  cleanup
  Adding migration for relations
  Added some fields (incipit, catalogue)

# Conflicts:
#	Gemfile.lock
  • Loading branch information
xhero committed Aug 8, 2018
2 parents 08f9db4 + 06e1902 commit c78c8e5
Show file tree
Hide file tree
Showing 23 changed files with 1,249 additions and 93 deletions.
7 changes: 7 additions & 0 deletions 7- RSPEC.rdoc
Expand Up @@ -18,6 +18,13 @@ Please prepare the correct folder structure for the test environment:

The schema will be loaded into a mysql database; all objects are created by FactoryBot during the suite.

==Requirements
For headless chrome: Chrome 59+ and ChromeDriver installed.
CHROME_DRIVER_VERSION=`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE`
wget -N http://chromedriver.storage.googleapis.com/$CHROME_DRIVER_VERSION/chromedriver_linux64.zip -P ~/
apt install gconf-service libgconf-2-4 libnspr4 libnss3 libpango1.0-0 libappindicator1 libcurl3
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb

This connects to the following sunspot-solr instance (see config/solr.yml):
test: &test
url: <%= ENV['SOLR_URL'] || "http://127.0.0.1:8981/solr/test" %>
Expand Down
3 changes: 2 additions & 1 deletion Gemfile
Expand Up @@ -143,6 +143,7 @@ group :test do
gem "rspec"
gem 'rspec-rails', '~> 3.5'
gem 'factory_bot_rails'
gem 'poltergeist', "1.11.0"
gem 'capybara'
gem 'selenium-webdriver'
gem 'database_cleaner'
end
23 changes: 12 additions & 11 deletions Gemfile.lock
Expand Up @@ -151,17 +151,18 @@ GEM
sass (>= 3.3.4)
builder (3.2.3)
cancan (1.6.10)
capybara (2.18.0)
capybara (3.5.1)
addressable
mini_mime (>= 0.1.3)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (>= 2.0, < 4.0)
nokogiri (~> 1.8)
rack (>= 1.6.0)
rack-test (>= 0.6.3)
xpath (~> 3.1)
chart-js-rails (0.1.6)
railties (> 3.1)
childprocess (0.9.0)
ffi (~> 1.0, >= 1.0.11)
climate_control (0.2.0)
cliver (0.3.2)
cocaine (0.5.8)
climate_control (>= 0.0.3, < 1.0)
coderay (1.1.2)
Expand Down Expand Up @@ -290,10 +291,6 @@ GEM
mimemagic (= 0.3.0)
parallel (1.12.1)
parslet (1.8.2)
poltergeist (1.11.0)
capybara (~> 2.1)
cliver (~> 0.3.1)
websocket-driver (>= 0.2.0)
polyamorous (1.3.3)
activerecord (>= 3.0)
pr_geohash (1.0.0)
Expand Down Expand Up @@ -390,6 +387,9 @@ GEM
tilt (>= 1.1, < 3)
sdoc (1.0.0)
rdoc (>= 5.0)
selenium-webdriver (3.14.0)
childprocess (~> 0.5)
rubyzip (~> 1.2)
solr_wrapper (2.0.0)
faraday
retriable
Expand Down Expand Up @@ -436,6 +436,7 @@ DEPENDENCIES
blacklight_range_limit!
bootstrap-sass
cancan
capybara
chart-js-rails
coffee-rails
colorize
Expand Down Expand Up @@ -463,7 +464,6 @@ DEPENDENCIES
paper_trail
paperclip (~> 4.3)
parallel
poltergeist (= 1.11.0)
progress_bar!
progress_job!
pry
Expand All @@ -478,6 +478,7 @@ DEPENDENCIES
ruby-prof
sass-rails
sdoc
selenium-webdriver
solr_wrapper (>= 0.3)
sunspot_rails (~> 2.2)!
sunspot_solr (~> 2.2)!
Expand Down
53 changes: 32 additions & 21 deletions app/assets/javascripts/viaf_interface.js
Expand Up @@ -54,28 +54,39 @@ var show_viaf_actions = function () {
}
}

$("#viaf_button").click(function(){
$viaf_table.html("");
var term = $("#viaf_input").val();
function searchViaf(){
$viaf_table.html("");
var term = $("#viaf_input").val();
var model = $("#marc_editor_panel").attr("data-editor-model");
$.ajax({
type: "GET",
url: "/admin/"+model+"/viaf.json?viaf_input="+term,
beforeSend: function() {
$('#loader').show();
},
complete: function(){
$('#loader').hide();
},
error: function(jqXHR, textStatus, errorThrown) {
alert(jqXHR.responseText);
},
success: function(data){
var result = (JSON.stringify(data));
drawTable(data);
}
});
});
$.ajax({
type: "GET",
url: "/admin/"+model+"/viaf.json?viaf_input="+term,
beforeSend: function() {
$('#loader').show();
},
complete: function(){
$('#loader').hide();
},
error: function(jqXHR, textStatus, errorThrown) {
alert(jqXHR.responseText);
},
success: function(data){
var result = (JSON.stringify(data));
drawTable(data);
}
});
}

$("#viaf_button").click(function(){
searchViaf()
})

$('#viaf_input').keydown(function (e) {
var keyCode = e.keyCode || e.which;
if (keyCode == 13) {
searchViaf()
}
});

function drawTable(data) {
for (var i = 0; i < data.length; i++) {
Expand Down
33 changes: 25 additions & 8 deletions app/models/work.rb
Expand Up @@ -16,6 +16,9 @@ class Work < ApplicationRecord
has_many :digital_object_links, :as => :object_link, :dependent => :delete_all
has_many :digital_objects, through: :digital_object_links, foreign_key: "object_link_id"
has_and_belongs_to_many(:referring_sources, class_name: "Source", join_table: "sources_to_works")
has_and_belongs_to_many :catalogues, join_table: "works_to_catalogues"
has_and_belongs_to_many :standard_terms, join_table: "works_to_standard_terms"
has_and_belongs_to_many :standard_titles, join_table: "works_to_standard_titles"
has_many :folder_items, as: :item, dependent: :destroy
has_many :delayed_jobs, -> { where parent_type: "Work" }, class_name: 'Delayed::Backend::ActiveRecord::Job', foreign_key: "parent_id"
belongs_to :user, :foreign_key => "wf_owner"
Expand All @@ -37,6 +40,7 @@ class Work < ApplicationRecord
enum wf_audit: [ :basic, :minimal, :full ]

alias_attribute :name, :title
alias_attribute :id_for_fulltext, :id

def after_initialize
@last_user_save = nil
Expand Down Expand Up @@ -84,7 +88,7 @@ def fix_ids
def update_links
return if self.suppress_recreate_trigger == true

allowed_relations = ["person"]
allowed_relations = ["person", "catalogues", "standard_terms", "standard_titles"]
recreate_links(marc, allowed_relations)
end

Expand Down Expand Up @@ -121,19 +125,32 @@ def reindex
self.index
end

searchable :auto_index => false do
integer :id
string :title_order do
searchable :auto_index => false do |sunspot_dsl|
sunspot_dsl.integer :id
sunspot_dsl.text :id_text do
id_for_fulltext
end
sunspot_dsl.string :title_order do
title
end
text :title
text :form
text :notes
sunspot_dsl.text :title
sunspot_dsl.text :title

sunspot_dsl.integer :wf_owner
sunspot_dsl.string :wf_stage
sunspot_dsl.time :updated_at
sunspot_dsl.time :created_at

integer :src_count_order, :stored => true do
sunspot_dsl.join(:folder_id, :target => FolderItem, :type => :integer,
:join => { :from => :item_id, :to => :id })

sunspot_dsl.integer :src_count_order, :stored => true do
Work.count_by_sql("select count(*) from sources_to_works where work_id = #{self[:id]}")
end

MarcIndex::attach_marc_index(sunspot_dsl, self.to_s.downcase)
end


def set_object_fields
return if marc_source == nil
Expand Down
15 changes: 15 additions & 0 deletions app/views/works/_show_variants.html.erb
@@ -0,0 +1,15 @@
<%
wv = tag.fetch_first_by_tag("n").content rescue ""
title = tag.fetch_first_by_tag("t").content rescue ""
key = tag.fetch_first_by_tag("r").content rescue ""
-%>
<tr class="row">
<th valign="top">
<% if (no_label == false) -%>
<%= @editor_profile.get_label(tag.tag) %>
<%- end %>
</th>
<td valign="top">
<%= "#{title} #{key} #{wv}" %>
</td>
</tr>

0 comments on commit c78c8e5

Please sign in to comment.