Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update of the validation process step 2 #2734

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion app/controllers/freecen_csv_entries_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ def accept
@freecen_csv_entry.update_attributes(warning_messages: '', record_valid: 'true')

@freecen_csv_entry.remove_flags if @freecen_csv_entry.flag

@freecen_csv_file = @freecen_csv_entry.freecen_csv_file
@freecen_csv_file.update_total_warning_messages
session[:propagate_alternate] = @freecen_csv_entry.id unless verbatim_place_of_birth_matches_place_of_birth(@freecen_csv_entry)
session[:propagate_note] = @freecen_csv_entry.id if @freecen_csv_entry.notes.present?
flash[:notice] = 'The acceptance was successful'
redirect_to(freecen_csv_entry_path(@freecen_csv_entry)) && return
end
Expand Down Expand Up @@ -253,6 +256,8 @@ def show
session[:current_list_entry] = @freecen_csv_entry.id if @next_list_entry.present? || @previous_list_entry.present?
session[:next_list_entry] = @next_list_entry.id if @next_list_entry.present?
session[:previous_list_entry] = @previous_list_entry.id if @previous_list_entry.present?
session[:propagate_alternate] = @freecen_csv_entry.id unless verbatim_place_of_birth_matches_place_of_birth(@freecen_csv_entry) || @freecen_csv_entry.record_valid == 'false'
session[:propagate_note] = @freecen_csv_entry.id if @freecen_csv_entry.notes.present? && @freecen_csv_entry.record_valid == 'true'
end

def update
Expand Down Expand Up @@ -302,6 +307,15 @@ def update_file_statistics(place)
@freecen_csv_file.save
end

def verbatim_place_of_birth_matches_place_of_birth(entry)

return true if entry.birth_county.blank? && entry.birth_place.blank?

return true if entry.verbatim_birth_county == entry.birth_county && entry.verbatim_birth_place == entry.birth_place

false
end

private

def freecen_csv_entry_params
Expand Down
4 changes: 4 additions & 0 deletions app/models/freecen_csv_entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1815,6 +1815,8 @@ def propagate?(parameters)

return true if parameters[:birth_place].present? && parameters[:birth_place] != birth_place

return true if birth_county != verbatim_birth_county || birth_place != verbatim_birth_place

false
end

Expand All @@ -1825,6 +1827,8 @@ def propagate_note?(parameters)

return true if parameters[:notes].present? && parameters[:notes] != notes

return true if notes.present?

false
end

Expand Down
6 changes: 6 additions & 0 deletions app/models/freecen_csv_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1273,6 +1273,12 @@ def update_messages_and_lock(original_warnings, original_errors, new_warnings, n
update_attributes(locked_by_transcriber: true, total_errors: new_number_errors, total_warnings: new_number_warnings)
end

def update_total_warning_messages
original_number_warnings = total_warnings
new_number_warnings = original_number_warnings - 1
update_attributes(total_warnings: new_number_warnings)
end

def update_freecen_piece
Freecen2Piece.update_or_create_piece(self)
end
Expand Down