Skip to content

Commit

Permalink
Update of the validation process step 2
Browse files Browse the repository at this point in the history
If Verbatim Place of Birth is not the same as the Alternative Place of Birth and records is valid then the Propagate POB action is available.
If Notes field is not null, then the Propagate Notes action is available.
Added adjustment of total warnings for the CSV file if warnings are accepted.
  • Loading branch information
AnneV-Learn committed Jun 28, 2024
1 parent d5b6efd commit 8d7514f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
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

0 comments on commit 8d7514f

Please sign in to comment.