From 8d7514f7c35777077b9b3bd42ff729a1aeacc854 Mon Sep 17 00:00:00 2001 From: Anne Vandervord <72746727+AnneV-Learn@users.noreply.github.com> Date: Fri, 28 Jun 2024 12:26:32 +0100 Subject: [PATCH 1/2] Update of the validation process step 2 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. --- .../freecen_csv_entries_controller.rb | 16 +++++++++++++++- app/models/freecen_csv_entry.rb | 4 ++++ app/models/freecen_csv_file.rb | 6 ++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/app/controllers/freecen_csv_entries_controller.rb b/app/controllers/freecen_csv_entries_controller.rb index f806ce14e..fd1d2221b 100644 --- a/app/controllers/freecen_csv_entries_controller.rb +++ b/app/controllers/freecen_csv_entries_controller.rb @@ -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 @@ -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 @@ -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 diff --git a/app/models/freecen_csv_entry.rb b/app/models/freecen_csv_entry.rb index 4dc4212de..c6f8347ed 100644 --- a/app/models/freecen_csv_entry.rb +++ b/app/models/freecen_csv_entry.rb @@ -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 @@ -1825,6 +1827,8 @@ def propagate_note?(parameters) return true if parameters[:notes].present? && parameters[:notes] != notes + return true if notes.present? + false end diff --git a/app/models/freecen_csv_file.rb b/app/models/freecen_csv_file.rb index 5c2bcc768..e2c825b8e 100644 --- a/app/models/freecen_csv_file.rb +++ b/app/models/freecen_csv_file.rb @@ -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 From c1b324fa599e054afdb7eccae9461884dcc4c24a Mon Sep 17 00:00:00 2001 From: Anne Vandervord <72746727+AnneV-Learn@users.noreply.github.com> Date: Fri, 19 Jul 2024 18:12:52 +0100 Subject: [PATCH 2/2] Once a POB is Propagated for a CSV record the 'Propagate Alternative fields' button does not display for that record. Once a POB is Propagated for a CSV record the 'Propagate Alternative fields' button does not display for that record. --- app/controllers/freecen_csv_entries_controller.rb | 3 ++- app/helpers/freecen_csv_entries_helper.rb | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/controllers/freecen_csv_entries_controller.rb b/app/controllers/freecen_csv_entries_controller.rb index fd1d2221b..aa99874c4 100644 --- a/app/controllers/freecen_csv_entries_controller.rb +++ b/app/controllers/freecen_csv_entries_controller.rb @@ -214,10 +214,11 @@ def propagate_alternate success, message = @freecen_csv_entry.propagate_alternate if success flash[:notice] = 'The propagation of the alternate fields was was successful, the file is now locked against replacement until it has been downloaded.' + session[:propagated_alternate] = session[:propagate_alternate] else flash[:notice] = "The propagation of the alternate fields failed because #{message}." + session.delete(:propagate_alternate) end - session.delete(:propagate_alternate) redirect_to freecen_csv_entry_path(@freecen_csv_entry) end diff --git a/app/helpers/freecen_csv_entries_helper.rb b/app/helpers/freecen_csv_entries_helper.rb index 71a306288..ddde4abe4 100644 --- a/app/helpers/freecen_csv_entries_helper.rb +++ b/app/helpers/freecen_csv_entries_helper.rb @@ -46,6 +46,8 @@ def accept_entry end def propagate_alternate + return if session[:propagate_alternate] == session[:propagated_alternate] + if session[:propagate_alternate].present? && session[:propagate_alternate] == @freecen_csv_entry.id && @year != '1841' link_to 'Propagate Alternate Fields', propagate_alternate_freecen_csv_entry_path(@freecen_csv_entry), method: :get, class: "btn btn--small", title: 'Propagates the alternate fields to entries with the same verbatim POB fields as this entry',