Skip to content
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
6 changes: 6 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,9 @@ def clean_session
session.delete(:contents_id)
session.delete(:contents_county_description)
session.delete(:contents_place_description)
session.delete(:propagate_alternate)
session.delete(:propagate_note)
session.delete(:propagated_alternate)
end

def clean_session_for_county
Expand Down Expand Up @@ -355,6 +358,9 @@ def clean_session_for_county
session.delete(:move_old_place)
session.delete(:move_new_county)
session.delete(:move_new_place)
session.delete(:propagate_alternate)
session.delete(:propagate_note)
session.delete(:propagated_alternate)
end

def clean_session_for_images
Expand Down
6 changes: 4 additions & 2 deletions app/controllers/freecen_csv_entries_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def accept
else
@propagation_fields = 'Notes'
end

@propagation_scope = 'File'
get_user_info_from_userid
warnings_adjustment, success, _message = @freecen_csv_entry.propagate_pob(@propagation_fields, @propagation_scope, @user.userid)
Expand Down Expand Up @@ -235,9 +236,10 @@ def propagate_pob
get_user_info_from_userid
warnings_adjustment, success, message = @freecen_csv_entry.propagate_pob(@propagation_fields, @propagation_scope, @user.userid)
if success
session[:propagated_alternate] = session[:propagate_alternate]
session[:propagated_alternate] = @propagation_fields == 'Notes' ? session[:propagate_note] : session[:propagate_alternate]
else
session.delete(:propagate_alternate)
session.delete(:propagate_note)
end
@freecen_csv_entry.reload
@freecen_csv_file = @freecen_csv_entry.freecen_csv_file
Expand Down Expand Up @@ -312,7 +314,7 @@ def update
else
flash[:notice] = 'The change in entry contents was successful, the file is now locked against replacement until it has been downloaded.'
end
redirect_to freecen_csv_entry_path(@freecen_csv_entry)
redirect_to(freecen_csv_entry_path(@freecen_csv_entry)) && return
end
end

Expand Down
11 changes: 7 additions & 4 deletions app/helpers/freecen_csv_entries_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,13 @@ def propagate_alternate
end
end

def propagate_note
return if session[:propagate_alternate] == session[:propagated_alternate] || @freecen_csv_file.incorporated
def propagate_notes

return if @freecen_csv_file.incorporated

return if session[:propagate_note].present? && session[:propagated_alternate].present? && session[:propagate_note] == session[:propagated_alternate]

if session[:propagate_note].present? && session[:propagate_note] == @freecen_csv_entry.id && @freecen_csv_entry.record_valid.downcase == 'true'
if session[:propagate_note].present? && session[:propagate_note] == @freecen_csv_entry.id && @freecen_csv_entry.record_valid.downcase == 'true' && @freecen_csv_entry.notes.present?
link_to 'Propagate Notes Field', propagate_pob_freecen_csv_entry_path(id: @freecen_csv_entry._id, propagation_fields: 'Notes'), method: :get, class: "btn btn--small",
title: 'Allows you to specify the scope of Propagation the Notes fields',
data: { confirm: 'Are you sure you want to Propagate the Notes of this entry' }
Expand All @@ -72,7 +75,7 @@ def propagate_note
def propagate_both
return if session[:propagate_alternate] == session[:propagated_alternate] || @freecen_csv_file.incorporated

if session[:propagate_alternate].present? && session[:propagate_note].present? && session[:propagate_alternate] == @freecen_csv_entry.id && @year != '1841' && @freecen_csv_entry.record_valid.downcase == 'true'
if session[:propagate_alternate].present? && session[:propagate_note].present? && session[:propagate_alternate] == @freecen_csv_entry.id && @year != '1841' && @freecen_csv_entry.record_valid.downcase == 'true' && @freecen_csv_entry.notes.present?
link_to 'Propagate POB and Notes Field', propagate_pob_freecen_csv_entry_path(id: @freecen_csv_entry._id, propagation_fields: 'Both'), method: :get, class: "btn btn--small",
title: 'Allows you to specify the scope of Propagation the alternative POB and Notes fields',
data: { confirm: 'Are you sure you want to Propagate the Alternate POB and Notes of this entry' }
Expand Down
57 changes: 41 additions & 16 deletions app/models/freecen_csv_entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,15 @@ def mytitlieze(value)
end

def propagation_scope(entry, chapman_code)
if entry.verbatim_birth_county == chapman_code ||
%w[OVF ENG SCT IRL WLS CHI].include?(entry.verbatim_birth_county) ||
(chapman_code == 'HAM' && %w[HAM IOW].include?(entry.verbatim_birth_county)) ||
(chapman_code == 'YKS' && %w[YKS ERY WRY NRY].include?(entry.verbatim_birth_county))
scope = 'Collection'
else
scope = 'File'
scope = 'File'
prop_rec_exists = FreecenPobPropagation.where(scope_year: 'ALL', scope_county: 'ALL', match_verbatim_birth_county: entry.verbatim_birth_county, match_verbatim_birth_place: entry.verbatim_birth_place).exists?
unless prop_rec_exists
if entry.verbatim_birth_county == chapman_code ||
%w[OVF ENG SCT IRL WLS CHI].include?(entry.verbatim_birth_county) ||
(chapman_code == 'HAM' && %w[HAM IOW].include?(entry.verbatim_birth_county)) ||
(chapman_code == 'YKS' && %w[YKS ERY WRY NRY].include?(entry.verbatim_birth_county))
scope = 'Collection'
end
end
scope
end
Expand Down Expand Up @@ -1746,7 +1748,7 @@ def acknowledge
end

def add_address(freecen_csv_file_id, dwelling)
first_individual = FreecenCsvEntry.find_by(freecen_csv_file_id: freecen_csv_file_id, dwelling_number: dwelling)
first_individual = FreecenCsvEntry.find_by(freecen_csv_file_id: freecen_csv_file_id, dwelling_number: dwelling, sequence_in_household: 1)
if first_individual.present?
self.folio_number = first_individual.folio_number
self.page_number = first_individual.page_number
Expand Down Expand Up @@ -1824,6 +1826,8 @@ def propagate?(parameters)

return false unless freecen_csv_file.validation

return false if birth_county.blank? && birth_place.blank?

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

return true if parameters[:birth_place].present? && parameters[:birth_place] != birth_place
Expand Down Expand Up @@ -1883,16 +1887,18 @@ def propagate_note(scope, userid)
need_review_message = 'Warning: Notes field has been adjusted and needs review.<br>'
if scope == 'ED'
FreecenCsvEntry.where(freecen_csv_file_id: freecen_csv_file_id, enumeration_district: enumeration_district, verbatim_birth_county: verbatim_birth_county, verbatim_birth_place: verbatim_birth_place).no_timeout.each do |entry|
next if entry.id == _id
next if entry.id == _id || entry.notes.upcase.include?(notes.upcase)


warning_message = entry.warning_messages + need_review_message
add_notes = entry.notes.present? ? entry.notes + ' ' + notes : notes
@warnings_adjustment += 1 if entry.warning_messages.blank?
entry.update_attributes(notes: add_notes, warning_messages: warning_message)

end
else
FreecenCsvEntry.where(freecen_csv_file_id: freecen_csv_file_id, verbatim_birth_county: verbatim_birth_county, verbatim_birth_place: verbatim_birth_place).no_timeout.each do |entry|
next if entry.id == _id
next if entry.id == _id || entry.notes.upcase.include?(notes.upcase)

warning_message = entry.warning_messages + need_review_message
add_notes = entry.notes.present? ? entry.notes + ' ' + notes : notes
Expand All @@ -1919,7 +1925,11 @@ def propagate_both(scope, userid)

_adjustment, updated_warnings = remove_pob_warning_messages(entry.warning_messages)
new_warning_message = updated_warnings + notes_need_review_message
add_notes = entry.notes.present? ? entry.notes + ' ' + notes : notes
if entry.notes.present? && entry.notes.upcase.include?(notes.upcase)
add_notes = entry.notes
else
add_notes = entry.notes.present? ? entry.notes + ' ' + notes : notes
end
@warnings_adjustment += 1 if entry.warning_messages.blank?
entry.update_attributes( birth_county: birth_county, birth_place: birth_place, notes: add_notes, warning_messages: new_warning_message)
end
Expand All @@ -1929,7 +1939,11 @@ def propagate_both(scope, userid)

_adjustment, updated_warnings = remove_pob_warning_messages(entry.warning_messages)
new_warning_message = updated_warnings + notes_need_review_message
add_notes = entry.notes.present? ? entry.notes + ' ' + notes : notes
if entry.notes.present? && entry.notes.upcase.include?(notes.upcase)
add_notes = entry.notes
else
add_notes = entry.notes.present? ? entry.notes + ' ' + notes : notes
end
@warnings_adjustment += 1 if entry.warning_messages.blank?
entry.update_attributes( birth_county: birth_county, birth_place: birth_place, notes: add_notes, warning_messages: new_warning_message)
end
Expand Down Expand Up @@ -2606,11 +2620,22 @@ def next_and_previous_list_entries(type)
return [nil, nil] if list_of_records.blank?

current_index = list_of_records.find_index(_id)
return [nil, nil] if current_index.blank?

number_records = list_of_records.length
next_entry = (current_index + 1) <= number_records ? FreecenCsvEntry.find_by(_id: list_of_records[current_index + 1]) : nil
previous_entry = (current_index - 1) < 0 ? nil : FreecenCsvEntry.find_by(_id: list_of_records[current_index - 1])
if current_index.present?
next_index = current_index + 1
previous_index = current_index - 1
else
previous_index = -1
next_index = number_records
list_of_records.each_with_index do |list_id, idx|
next_index = idx
break if list_id > _id

previous_index = idx
end
end
next_entry = next_index < number_records && next_index != previous_index ? FreecenCsvEntry.find_by(_id: list_of_records[next_index]) : nil
previous_entry = previous_index.negative? ? nil : FreecenCsvEntry.find_by(_id: list_of_records[previous_index])
[next_entry, previous_entry]
end

Expand Down
2 changes: 1 addition & 1 deletion app/views/freecen_csv_entries/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<br>
<%= edit_entry %>
<%= propagate_alternate%>
<%= propagate_note%>
<%= propagate_notes%>
<%= propagate_both%>
<%= accept_entry %>
<%= reject_entry %>
Expand Down