Skip to content

Commit

Permalink
Merge 97b4c81 into bf594bb
Browse files Browse the repository at this point in the history
  • Loading branch information
benwbrum committed Feb 17, 2022
2 parents bf594bb + 97b4c81 commit 2f4b3c9
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 14 deletions.
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions app/controllers/collection_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions app/models/collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
10 changes: 5 additions & 5 deletions app/views/collection/edit.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions app/views/dashboard/landing_page.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion config/locales/collection/collection.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.)"
Expand Down
8 changes: 4 additions & 4 deletions spec/features/disable_subjects_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2f4b3c9

Please sign in to comment.