Skip to content

Commit

Permalink
Merge pull request #1541 from benwbrum/1507-mark-blank-redirect
Browse files Browse the repository at this point in the history
Mark blank redirect to transcribe view
  • Loading branch information
benwbrum committed Oct 9, 2019
2 parents c04339c + 73e8661 commit 0c71d22
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
19 changes: 15 additions & 4 deletions app/controllers/transcribe_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,31 @@ def display_page
def guest
end

def mark_page_blank
def mark_page_blank(options = { redirect: 'display' })
redirect_path = case options[:redirect]
when 'transcribe'
collection_transcribe_page_path(@collection.owner, @collection, @page.work, @page.id)
else
collection_display_page_path(@collection.owner, @collection, @page.work, @page.id)
end

if params[:page]['mark_blank'] == '1'
@page.status = Page::STATUS_BLANK
@page.translation_status = Page::STATUS_BLANK
@page.save
record_deed(DeedType::PAGE_MARKED_BLANK)
@work.work_statistic.recalculate({type: 'blank'}) if @work.work_statistic
redirect_to collection_display_page_path(@collection.owner, @collection, @page.work, @page.id) and return
flash[:notice] = "Saved"
redirect_to redirect_path
return false
elsif @page.status == Page::STATUS_BLANK && params[:page]['mark_blank'] == '0'
@page.status = nil
@page.translation_status = nil
@page.save
@work.work_statistic.recalculate({type: 'blank'}) if @work.work_statistic
redirect_to collection_display_page_path(@collection.owner, @collection, @page.work, @page.id) and return
flash[:notice] = "Saved"
redirect_to redirect_path
return false
else
return true
end
Expand Down Expand Up @@ -100,7 +111,7 @@ def save_transcription
@page.attributes = params[:page]
#if page has been marked blank, call the mark_blank code
unless params[:page]['needs_review'] == '1'
mark_page_blank or return
mark_page_blank(redirect: 'transcribe') or return
end
#check to see if the page needs to be marked as needing review
needs_review
Expand Down
2 changes: 0 additions & 2 deletions spec/features/editor_actions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
page.find('.tabs').click_link("Transcribe")
page.find('#page_mark_blank').set(true)
page.find('#save_button_top').click

page.find('.tabs').click_link("Transcribe")
expect(page).to have_checked_field('page_mark_blank')
end
it "resets page status to nil if empty and not marked BLANK" do
Expand Down
4 changes: 2 additions & 2 deletions spec/features/needs_review_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@
page.find('.work-page_title', text: @page1.title).click_link(@page1.title)
page.check('page_mark_blank')
find('#save_button_top').click
expect(page).to have_content("This page is blank")
expect(page).to have_content("This page is marked blank")
expect(Page.find_by(id: @page1.id).status).to eq ('blank')
expect(Page.find_by(id: @page1.id).translation_status).to eq ('blank')
page.find('.page-nav_next').click
page.find('.tabs').click_link("Overview")
expect(page).to have_content(@page2.title)
expect(page).to have_content("This page is not transcribed")
page.find('a', text: 'mark the page blank').click
expect(page).to have_content("This page is blank")
expect(page).to have_content("This page is blank")
expect(Page.find_by(id: @page2.id).status).to eq ('blank')
expect(Page.find_by(id: @page2.id).translation_status).to eq ('blank')
end
Expand Down

0 comments on commit 0c71d22

Please sign in to comment.