diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index ddc462d3e4..d444609ffe 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -60,7 +60,7 @@ def current_user #find the guest user account if a guest user session is currently active def guest_user unless session[:guest_user_id].nil? - User.find(session[:guest_user_id]) + User.where(id: session[:guest_user_id]).first end end diff --git a/app/controllers/collection_controller.rb b/app/controllers/collection_controller.rb index 47b0980819..e656cb30d8 100644 --- a/app/controllers/collection_controller.rb +++ b/app/controllers/collection_controller.rb @@ -357,6 +357,8 @@ def edit end def update + @collection.subjects_disabled = (params[:collection][:subjects_enabled] == "0") #:subjects_enabled is "0" or "1" + if params[:collection][:slug] == "" @collection.update(collection_params.except(:slug)) title = @collection.title.parameterize diff --git a/app/models/collection.rb b/app/models/collection.rb index 2c62c08c0f..9033edc770 100644 --- a/app/models/collection.rb +++ b/app/models/collection.rb @@ -70,6 +70,10 @@ def text_entry? def metadata_entry? self.data_entry_type == DataEntryType::TEXT_AND_METADATA || self.data_entry_type == DataEntryType::METADATA_ONLY end + + def subjects_enabled + !subjects_disabled + end module ReviewType OPTIONAL = 'optional' diff --git a/app/views/collection/edit.html.slim b/app/views/collection/edit.html.slim index ebaa9be552..09b4c2eeb7 100644 --- a/app/views/collection/edit.html.slim +++ b/app/views/collection/edit.html.slim @@ -41,16 +41,16 @@ =f.text_area :link_help, rows: 10, value: @collection.link_help tr td(colspan="2") - =f.check_box :subjects_disabled, value: @collection.subjects_disabled - =f.label :subjects_disabled, t('.subjects_disabled') + =f.check_box :subjects_enabled + =f.label :subjects_enabled, t('.subjects_enabled') tr td(colspan="2") - =f.check_box :hide_completed, value: @collection.hide_completed + =f.check_box :hide_completed =f.label :hide_completed, t('.hide_completed') -if @collection.text_entry? tr td(colspan="2") - =f.check_box :user_download, value: @collection.user_download + =f.check_box :user_download =f.label :user_download, t('.user_download') tr td(colspan="2") @@ -65,7 +65,7 @@ -if @ssl && !@collection.field_based && @collection.text_entry? tr td(colspan="2") - =f.check_box :voice_recognition, value: @collection.voice_recognition, onchange: 'showLang(event)' + =f.check_box :voice_recognition, onchange: 'showLang(event)' =f.label :voice_recognition, t('.voice_recognition') -if @collection.text_entry? tr diff --git a/app/views/dashboard/landing_page.html.slim b/app/views/dashboard/landing_page.html.slim index f4be29f243..7fd059c0d3 100644 --- a/app/views/dashboard/landing_page.html.slim +++ b/app/views/dashboard/landing_page.html.slim @@ -3,7 +3,7 @@ -@collections.each do |c| -cache c do -link_page = c.next_untranscribed_page - -snippet = truncate(strip_tags(c.intro_block), length: 300, separator: ' ') || '' + -snippet = truncate(Loofah.fragment(c.intro_block).text(encode_special_chars: false), length: 300, separator: ' ') || '' .carousel_slide =link_to image_tag(c.picture_url, alt: c.title), collection_path(c.owner, c), class: 'carousel_slide_image' .carousel_slide_content @@ -31,7 +31,7 @@ h5 =link_to sr.title, collection_path(sr.owner.slug, sr.id) .projects_collection_snippet - = truncate(strip_tags(sr.intro_block), length: 300, separator: ' ') || '' + = truncate(Loofah.fragment(sr.intro_block).text(encode_special_chars: false), length: 300, separator: ' ') || '' -@owners.each do |owner| -if params[:search] -projects = @search_results.select{ |p| p.owner_user_id == owner.id} @@ -47,7 +47,7 @@ =owner.about .projects -projects.each do |project| - -snippet = truncate(strip_tags(project.intro_block), length: 300, separator: ' ') || '' + -snippet = truncate(Loofah.fragment(project.intro_block).text(encode_special_chars: false), length: 300, separator: ' ') || '' div.projects_details -unless project.picture.blank? .projects_details_image diff --git a/config/locales/collection/collection.en.yml b/config/locales/collection/collection.en.yml index 74f1ece818..392d6d9867 100644 --- a/config/locales/collection/collection.en.yml +++ b/config/locales/collection/collection.en.yml @@ -80,7 +80,7 @@ en: help: "Basic Help Text" suggestions_help_tab: "Suggestions for your help tab." link_help: "Subject Linking Help Text (not displayed if subjects are disabled)" - subjects_disabled: "Disable subject indexing" + subjects_enabled: "Enable subject indexing" review_type: "Review Type" review_type_optional: " Optional: Collaborators may request review of their transcriptions." review_type_required: " Required: All initial transcriptions will be marked as needing review. (Review may be performed by anyone.)" diff --git a/spec/features/disable_subjects_spec.rb b/spec/features/disable_subjects_spec.rb index d392271a0c..348c087605 100644 --- a/spec/features/disable_subjects_spec.rb +++ b/spec/features/disable_subjects_spec.rb @@ -17,8 +17,8 @@ it "disables subject indexing in a collection" do visit collection_path(@collection.owner, @collection) page.find('.tabs').click_link("Settings") - expect(page).to have_content("Disable subject indexing") - check('collection_subjects_disabled') + expect(page).to have_content("Enable subject indexing") + uncheck('collection_subjects_enabled') click_button('Save Changes') #have to find the collection again to make sure it's been updated collection = Collection.where(owner_user_id: @owner.id).first @@ -90,8 +90,8 @@ it "enables subject indexing" do visit collection_path(@collection.owner, @collection) page.find('.tabs').click_link("Settings") - expect(page).to have_content("Disable subject indexing") - uncheck('collection_subjects_disabled') + expect(page).to have_content("Enable subject indexing") + check('collection_subjects_enabled') click_button('Save Changes') #have to find the collection again to make sure it's been updated collection = Collection.where(owner_user_id: @owner.id).first