diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index 0b2470a206..f474b899a0 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -1,4 +1,4 @@
# https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners
-* @compwron @FireLemons @littleforest @elasticspoon
+* @compwron @FireLemons @elasticspoon
/app/javascript/ @schoork @FireLemons @elasticspoon
diff --git a/Gemfile.lock b/Gemfile.lock
index 896a55353e..515757b170 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -153,7 +153,7 @@ GEM
cssbundling-rails (1.4.0)
railties (>= 6.0.0)
csv (3.3.0)
- database_cleaner-active_record (2.1.0)
+ database_cleaner-active_record (2.2.0)
activerecord (>= 5.a)
database_cleaner-core (~> 2.0.0)
database_cleaner-core (2.0.1)
@@ -177,10 +177,10 @@ GEM
docx (0.8.0)
nokogiri (~> 1.13, >= 1.13.0)
rubyzip (~> 2.0)
- dotenv (2.8.1)
- dotenv-rails (2.8.1)
- dotenv (= 2.8.1)
- railties (>= 3.2)
+ dotenv (3.1.2)
+ dotenv-rails (3.1.2)
+ dotenv (= 3.1.2)
+ railties (>= 6.1)
draper (4.0.2)
actionpack (>= 5.0)
activemodel (>= 5.0)
@@ -206,7 +206,7 @@ GEM
factory_bot_rails (6.4.3)
factory_bot (~> 6.4)
railties (>= 5.0.0)
- faker (3.4.1)
+ faker (3.4.2)
i18n (>= 1.8.11, < 2)
faraday (1.10.3)
faraday-em_http (~> 1.0)
@@ -486,7 +486,7 @@ GEM
nokogiri (>= 1.12.0)
scout_apm (5.3.8)
parser
- selenium-webdriver (4.22.0)
+ selenium-webdriver (4.23.0)
base64 (~> 0.2)
logger (~> 1.4)
rexml (~> 3.2, >= 3.2.5)
@@ -557,7 +557,7 @@ GEM
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
webrick (1.8.1)
- websocket (1.2.10)
+ websocket (1.2.11)
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
diff --git a/app/callbacks/case_contact_metadata_callback.rb b/app/callbacks/case_contact_metadata_callback.rb
new file mode 100644
index 0000000000..1fa7f0c15d
--- /dev/null
+++ b/app/callbacks/case_contact_metadata_callback.rb
@@ -0,0 +1,25 @@
+class CaseContactMetadataCallback
+ def after_commit(case_contact)
+ changes = case_contact.saved_changes
+
+ set_status(changes, case_contact) if changes["id"]
+ update_status(changes, case_contact) if changes["status"] && changes["id"].nil?
+ end
+
+ private
+
+ def set_status(changes, case_contact)
+ metadata = {"status" => {case_contact.status => case_contact.created_at}}
+ update_metadata(case_contact, metadata)
+ end
+
+ def update_status(changes, case_contact)
+ metadata = {"status" => {changes["status"].last => Time.zone.now}}
+ update_metadata(case_contact, metadata)
+ end
+
+ def update_metadata(record, new_data)
+ metadata = record.metadata.deep_merge(new_data)
+ record.update_columns(metadata: metadata)
+ end
+end
diff --git a/app/controllers/all_casa_admins/casa_admins_controller.rb b/app/controllers/all_casa_admins/casa_admins_controller.rb
index 275cc6adc2..5b39683104 100644
--- a/app/controllers/all_casa_admins/casa_admins_controller.rb
+++ b/app/controllers/all_casa_admins/casa_admins_controller.rb
@@ -12,7 +12,7 @@ def create
service.create!
redirect_to all_casa_admins_casa_org_path(@casa_org), notice: "New admin created successfully"
rescue ActiveRecord::RecordInvalid
- render :new
+ render :new, status: :unprocessable_entity
end
end
@@ -28,7 +28,7 @@ def update
@casa_admin.filter_old_emails!(@casa_admin.email)
redirect_to edit_all_casa_admins_casa_org_casa_admin_path(@casa_org), notice: notice
else
- render :edit
+ render :edit, status: :unprocessable_entity
end
end
@@ -39,7 +39,7 @@ def activate
redirect_to edit_all_casa_admins_casa_org_casa_admin_path, notice: "Admin was activated. They have been sent an email."
else
- render :edit
+ render :edit, status: :unprocessable_entity
end
end
@@ -50,7 +50,7 @@ def deactivate
redirect_to edit_all_casa_admins_casa_org_casa_admin_path, notice: "Admin was deactivated."
else
- render :edit
+ render :edit, status: :unprocessable_entity
end
end
diff --git a/app/controllers/all_casa_admins/casa_orgs_controller.rb b/app/controllers/all_casa_admins/casa_orgs_controller.rb
index 8bd740c3d6..cc1faf8565 100644
--- a/app/controllers/all_casa_admins/casa_orgs_controller.rb
+++ b/app/controllers/all_casa_admins/casa_orgs_controller.rb
@@ -25,7 +25,7 @@ def create
end
else
respond_to do |format|
- format.html { render :new }
+ format.html { render :new, status: :unprocessable_entity }
format.json { render json: @casa_org.errors.full_messages, status: :unprocessable_entity }
end
end
diff --git a/app/controllers/all_casa_admins_controller.rb b/app/controllers/all_casa_admins_controller.rb
index 5ab4cf648f..b8918314e5 100644
--- a/app/controllers/all_casa_admins_controller.rb
+++ b/app/controllers/all_casa_admins_controller.rb
@@ -30,7 +30,7 @@ def create
end
rescue ActiveRecord::RecordInvalid
respond_to do |format|
- format.html { render :new }
+ format.html { render :new, status: :unprocessable_entity }
format.json do
render json: @all_casa_admin.errors.full_messages, status: :unprocessable_entity
@@ -53,7 +53,7 @@ def update
end
else
respond_to do |format|
- format.html { render :edit }
+ format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @user.errors.full_messages, status: :unprocessable_entity }
end
end
@@ -78,7 +78,7 @@ def update_password
end
else
respond_to do |format|
- format.html { render :edit }
+ format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @user.errors.full_messages, status: :unprocessable_entity }
end
end
diff --git a/app/controllers/banners_controller.rb b/app/controllers/banners_controller.rb
index b9ab11d91e..46dc68ba5e 100644
--- a/app/controllers/banners_controller.rb
+++ b/app/controllers/banners_controller.rb
@@ -35,7 +35,7 @@ def create
redirect_to banners_path
rescue
- render :new
+ render :new, status: :unprocessable_entity
end
def update
@@ -48,7 +48,7 @@ def update
redirect_to banners_path
rescue
- render :edit
+ render :edit, status: :unprocessable_entity
end
def destroy
diff --git a/app/controllers/bulk_court_dates_controller.rb b/app/controllers/bulk_court_dates_controller.rb
index 85885a40de..ef2be1d2c6 100644
--- a/app/controllers/bulk_court_dates_controller.rb
+++ b/app/controllers/bulk_court_dates_controller.rb
@@ -15,7 +15,7 @@ def create
case_group_id = params[:court_date][:case_group_id]
if case_group_id.empty?
@court_date = build_court_date_with_error_message
- render :new
+ render :new, status: :unprocessable_entity
return
end
@@ -26,7 +26,7 @@ def create
if court_date_with_error
@court_date = court_date_with_error
- render :new
+ render :new, status: :unprocessable_entity
else
redirect_to new_bulk_court_date_path, notice: "#{court_dates.size} #{"court date".pluralize(court_dates.size)} created!"
end
diff --git a/app/controllers/casa_admins_controller.rb b/app/controllers/casa_admins_controller.rb
index cd78106239..39fa8acf89 100644
--- a/app/controllers/casa_admins_controller.rb
+++ b/app/controllers/casa_admins_controller.rb
@@ -26,7 +26,7 @@ def update
end
else
respond_to do |format|
- format.html { render :edit }
+ format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @casa_admin.errors.full_messages, status: :unprocessable_entity }
end
end
@@ -59,7 +59,7 @@ def create
end
rescue ActiveRecord::RecordInvalid
respond_to do |format|
- format.html { render :new }
+ format.html { render :new, status: :unprocessable_entity }
format.json { render json: service.casa_admin.errors.full_messages, status: :unprocessable_entity }
end
end
@@ -81,7 +81,7 @@ def activate
end
else
respond_to do |format|
- format.html { render :edit }
+ format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @casa_admin.errors.full_messages, status: :unprocessable_entity }
end
end
@@ -100,7 +100,7 @@ def deactivate
end
else
respond_to do |format|
- format.html { render :edit }
+ format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @casa_admin.errors.full_messages, status: :unprocessable_entity }
end
end
diff --git a/app/controllers/casa_cases_controller.rb b/app/controllers/casa_cases_controller.rb
index a3869db3c7..c3b059a31d 100644
--- a/app/controllers/casa_cases_controller.rb
+++ b/app/controllers/casa_cases_controller.rb
@@ -59,7 +59,7 @@ def create
set_contact_types
@empty_court_date = court_date_unknown?
respond_to do |format|
- format.html { render :new }
+ format.html { render :new, status: :unprocessable_entity }
format.json { render json: @casa_case.errors.full_messages, status: :unprocessable_entity }
end
end
@@ -79,7 +79,7 @@ def update
end
else
respond_to do |format|
- format.html { render :edit }
+ format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @casa_case.errors.full_messages, status: :unprocessable_entity }
end
end
@@ -101,7 +101,7 @@ def deactivate
end
else
respond_to do |format|
- format.html { render :edit }
+ format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @casa_case.errors.full_messages, status: :unprocessable_entity }
end
end
@@ -123,7 +123,7 @@ def reactivate
end
else
respond_to do |format|
- format.html { render :edit }
+ format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @casa_case.errors.full_messages, status: :unprocessable_entity }
end
end
diff --git a/app/controllers/casa_org_controller.rb b/app/controllers/casa_org_controller.rb
index 77392b4ee1..16bc3d7701 100644
--- a/app/controllers/casa_org_controller.rb
+++ b/app/controllers/casa_org_controller.rb
@@ -28,7 +28,7 @@ def update
end
else
respond_to do |format|
- format.html { render :edit }
+ format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @casa_org.errors.full_messages, status: :unprocessable_entity }
end
end
diff --git a/app/controllers/case_assignments_controller.rb b/app/controllers/case_assignments_controller.rb
index 4096ee0c0a..4737f0fc0c 100644
--- a/app/controllers/case_assignments_controller.rb
+++ b/app/controllers/case_assignments_controller.rb
@@ -53,7 +53,7 @@ def unassign
end
else
respond_to do |format|
- format.html { render :edit }
+ format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @case_assignment.errors.full_messages, status: :unprocessable_entity }
end
end
diff --git a/app/controllers/case_contacts/form_controller.rb b/app/controllers/case_contacts/form_controller.rb
index d988c98bdf..350e2b8bba 100644
--- a/app/controllers/case_contacts/form_controller.rb
+++ b/app/controllers/case_contacts/form_controller.rb
@@ -24,7 +24,7 @@ def update
remove_unwanted_contact_types
remove_nil_draft_ids
- if CaseContactUpdateService.new(@case_contact).update_attrs(case_contact_params)
+ if @case_contact.update(case_contact_params)
respond_to do |format|
format.html {
if step == steps.last
diff --git a/app/controllers/case_groups_controller.rb b/app/controllers/case_groups_controller.rb
index b69f98798a..1fda7b9131 100644
--- a/app/controllers/case_groups_controller.rb
+++ b/app/controllers/case_groups_controller.rb
@@ -19,7 +19,7 @@ def create
if @case_group.save
redirect_to case_groups_path, notice: "Case group created!"
else
- render :new
+ render :new, status: :unprocessable_entity
end
end
@@ -28,7 +28,7 @@ def update
if @case_group.update(case_group_params)
redirect_to case_groups_path, notice: "Case group updated!"
else
- render :new
+ render :new, status: :unprocessable_entity
end
end
diff --git a/app/controllers/checklist_items_controller.rb b/app/controllers/checklist_items_controller.rb
index 4bf78c94fb..0d55fdfece 100644
--- a/app/controllers/checklist_items_controller.rb
+++ b/app/controllers/checklist_items_controller.rb
@@ -13,7 +13,7 @@ def create
set_checklist_updated_date(@hearing_type)
redirect_to edit_hearing_type_path(@hearing_type), notice: "Checklist item was successfully created."
else
- render :new
+ render :new, status: :unprocessable_entity
end
end
@@ -25,7 +25,7 @@ def update
set_checklist_updated_date(@hearing_type)
redirect_to edit_hearing_type_path(@hearing_type), notice: "Checklist item was successfully updated."
else
- render :edit
+ render :edit, status: :unprocessable_entity
end
end
diff --git a/app/controllers/contact_type_groups_controller.rb b/app/controllers/contact_type_groups_controller.rb
index 3e137680e0..dc2e606925 100644
--- a/app/controllers/contact_type_groups_controller.rb
+++ b/app/controllers/contact_type_groups_controller.rb
@@ -14,7 +14,7 @@ def create
if @contact_type_group.save
redirect_to edit_casa_org_path(current_organization), notice: "Contact Type Group was successfully created."
else
- render :new
+ render :new, status: :unprocessable_entity
end
end
@@ -27,7 +27,7 @@ def update
if @contact_type_group.update(contact_type_group_params)
redirect_to edit_casa_org_path(current_organization), notice: "Contact Type Group was successfully updated."
else
- render :edit
+ render :edit, status: :unprocessable_entity
end
end
diff --git a/app/controllers/contact_types_controller.rb b/app/controllers/contact_types_controller.rb
index 68af9cb77d..5ca8a7966d 100644
--- a/app/controllers/contact_types_controller.rb
+++ b/app/controllers/contact_types_controller.rb
@@ -14,7 +14,7 @@ def create
if @contact_type.save
redirect_to edit_casa_org_path(current_organization), notice: "Contact Type was successfully created."
else
- render :new
+ render :new, status: :unprocessable_entity
end
end
@@ -27,7 +27,7 @@ def update
if @contact_type.update(contact_type_params)
redirect_to edit_casa_org_path(current_organization), notice: "Contact Type was successfully updated."
else
- render :edit
+ render :edit, status: :unprocessable_entity
end
end
diff --git a/app/controllers/court_dates_controller.rb b/app/controllers/court_dates_controller.rb
index fab87c8fea..e65cc01451 100644
--- a/app/controllers/court_dates_controller.rb
+++ b/app/controllers/court_dates_controller.rb
@@ -38,7 +38,7 @@ def create
if @court_date.save && @casa_case.save
redirect_to casa_case_court_date_path(@casa_case, @court_date), notice: "Court date was successfully created."
else
- render :new
+ render :new, status: :unprocessable_entity
end
end
@@ -47,7 +47,7 @@ def update
if @court_date.update(court_date_params(@casa_case))
redirect_to casa_case_court_date_path(@casa_case, @court_date), notice: "Court date was successfully updated."
else
- render :edit
+ render :edit, status: :unprocessable_entity
end
end
diff --git a/app/controllers/fund_requests_controller.rb b/app/controllers/fund_requests_controller.rb
index 77c049c66b..f2a1aa9bf2 100644
--- a/app/controllers/fund_requests_controller.rb
+++ b/app/controllers/fund_requests_controller.rb
@@ -15,7 +15,7 @@ def create
FundRequestMailer.send_request(nil, @fund_request).deliver
redirect_to casa_case_path(@casa_case), notice: "Fund Request was sent for case #{@casa_case.case_number}"
else
- render :new
+ render :new, status: :unprocessable_entity
end
end
diff --git a/app/controllers/hearing_types_controller.rb b/app/controllers/hearing_types_controller.rb
index 58820a45d0..42c2592e7d 100644
--- a/app/controllers/hearing_types_controller.rb
+++ b/app/controllers/hearing_types_controller.rb
@@ -14,7 +14,7 @@ def create
if @hearing_type.save
redirect_to edit_casa_org_path(current_organization), notice: "Hearing Type was successfully created."
else
- render :new
+ render :new, status: :unprocessable_entity
end
end
@@ -27,7 +27,7 @@ def update
if @hearing_type.update(hearing_type_params)
redirect_to edit_casa_org_path(current_organization), notice: "Hearing Type was successfully updated."
else
- render :edit
+ render :edit, status: :unprocessable_entity
end
end
diff --git a/app/controllers/judges_controller.rb b/app/controllers/judges_controller.rb
index 4a6b179fc9..0b3226e5c9 100644
--- a/app/controllers/judges_controller.rb
+++ b/app/controllers/judges_controller.rb
@@ -14,7 +14,7 @@ def create
if @judge.save
redirect_to edit_casa_org_path(current_organization), notice: "Judge was successfully created."
else
- render :new
+ render :new, status: :unprocessable_entity
end
end
@@ -27,7 +27,7 @@ def update
if @judge.update(judge_params)
redirect_to edit_casa_org_path(current_organization), notice: "Judge was successfully updated."
else
- render :edit
+ render :edit, status: :unprocessable_entity
end
end
diff --git a/app/controllers/learning_hour_topics_controller.rb b/app/controllers/learning_hour_topics_controller.rb
index 7063e9ff65..7be8198c61 100644
--- a/app/controllers/learning_hour_topics_controller.rb
+++ b/app/controllers/learning_hour_topics_controller.rb
@@ -18,7 +18,7 @@ def create
if @learning_hour_topic.save
redirect_to edit_casa_org_path(current_organization), notice: "Learning Topic was successfully created."
else
- render :new
+ render :new, status: :unprocessable_entity
end
end
@@ -28,7 +28,7 @@ def update
if @learning_hour_topic.update(learning_hour_topic_params)
redirect_to edit_casa_org_path(current_organization), notice: "Learning Topic was successfully updated."
else
- render :edit
+ render :edit, status: :unprocessable_entity
end
end
diff --git a/app/controllers/learning_hour_types_controller.rb b/app/controllers/learning_hour_types_controller.rb
index 45ab790d33..62b7cb35c5 100644
--- a/app/controllers/learning_hour_types_controller.rb
+++ b/app/controllers/learning_hour_types_controller.rb
@@ -18,7 +18,7 @@ def create
if @learning_hour_type.save
redirect_to edit_casa_org_path(current_organization), notice: "Learning Type was successfully created."
else
- render :new
+ render :new, status: :unprocessable_entity
end
end
@@ -28,7 +28,7 @@ def update
if @learning_hour_type.update(learning_hour_type_params)
redirect_to edit_casa_org_path(current_organization), notice: "Learning Type was successfully updated."
else
- render :edit
+ render :edit, status: :unprocessable_entity
end
end
diff --git a/app/controllers/learning_hours_controller.rb b/app/controllers/learning_hours_controller.rb
index 0469012c8e..f506fae93f 100644
--- a/app/controllers/learning_hours_controller.rb
+++ b/app/controllers/learning_hours_controller.rb
@@ -24,7 +24,7 @@ def create
if @learning_hour.save
format.html { redirect_to learning_hours_path, notice: "New entry was successfully created." }
else
- format.html { render :new, status: 404 }
+ format.html { render :new, status: :unprocessable_entity }
end
end
end
@@ -39,7 +39,7 @@ def update
if @learning_hour.update(update_learning_hours_params)
format.html { redirect_to learning_hour_path(@learning_hour), notice: "Entry was successfully updated." }
else
- format.html { render :edit, status: 404 }
+ format.html { render :edit, status: :unprocessable_entity }
end
end
end
diff --git a/app/controllers/mileage_rates_controller.rb b/app/controllers/mileage_rates_controller.rb
index 4ff2c6704b..ae8c1d376e 100644
--- a/app/controllers/mileage_rates_controller.rb
+++ b/app/controllers/mileage_rates_controller.rb
@@ -18,7 +18,7 @@ def create
if @mileage_rate.save
redirect_to mileage_rates_path
else
- render :new
+ render :new, status: :unprocessable_entity
end
end
@@ -32,7 +32,7 @@ def update
if @mileage_rate.update(mileage_rate_params)
redirect_to mileage_rates_path
else
- render :edit
+ render :edit, status: :unprocessable_entity
end
end
diff --git a/app/controllers/supervisor_volunteers_controller.rb b/app/controllers/supervisor_volunteers_controller.rb
index 344af4f849..deb8d8e79a 100644
--- a/app/controllers/supervisor_volunteers_controller.rb
+++ b/app/controllers/supervisor_volunteers_controller.rb
@@ -17,8 +17,8 @@ def create
def unassign
authorize :supervisor_volunteer
volunteer = Volunteer.find(params[:id])
- supervisor = volunteer.supervisor_volunteer.supervisor
if unassign_volunteers_supervisor(volunteer)
+ supervisor = volunteer.supervisor_volunteer.supervisor
flash[:notice] = "#{volunteer.display_name} was unassigned from #{supervisor.display_name}."
else
flash[:alert] = "Something went wrong. Please try again."
diff --git a/app/controllers/supervisors_controller.rb b/app/controllers/supervisors_controller.rb
index b4834fce01..42e1bdd5fd 100644
--- a/app/controllers/supervisors_controller.rb
+++ b/app/controllers/supervisors_controller.rb
@@ -35,7 +35,7 @@ def create
sms_status = deliver_sms_to @supervisor, body_msg
redirect_to edit_supervisor_path(@supervisor), notice: sms_acct_creation_notice("supervisor", sms_status)
else
- render new_supervisor_path
+ render new_supervisor_path, status: :unprocessable_entity
end
end
@@ -55,7 +55,7 @@ def update
@supervisor.filter_old_emails!(@supervisor.email)
redirect_to edit_supervisor_path(@supervisor), notice: notice
else
- render :edit
+ render :edit, status: :unprocessable_entity
end
end
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 9eae2a1cac..144d4d3df7 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -16,19 +16,19 @@ def update
flash[:success] = "Profile was successfully updated."
redirect_to edit_users_path
else
- render :edit
+ render :edit, status: :unprocessable_entity
end
end
def add_language
if @language.nil?
@user.errors.add(:language_id, "can not be blank. Please select a language before adding.")
- return render "edit"
+ return render "edit", status: :unprocessable_entity
end
if current_user.languages.include?(@language)
@user.errors.add(:language_id, "#{@language.name} is already in your languages list.")
- return render "edit"
+ return render "edit", status: :unprocessable_entity
end
current_user.languages << @language
@@ -54,11 +54,11 @@ def remove_language
def update_password
unless valid_user_password
@user.errors.add(:base, "Current password is incorrect")
- return render "edit"
+ return render "edit", status: :unprocessable_entity
end
unless update_user_password
- return render "edit"
+ return render "edit", status: :unprocessable_entity
end
bypass_sign_in(@user) if @user == true_user
@@ -72,11 +72,11 @@ def update_password
def update_email
unless valid_user_password
@user.errors.add(:base, "Current password is incorrect")
- return render "edit"
+ return render "edit", status: :unprocessable_entity
end
unless update_user_email
- return render "edit"
+ return render "edit", status: :unprocessable_entity
end
bypass_sign_in(@user) if @user == true_user
diff --git a/app/controllers/volunteers_controller.rb b/app/controllers/volunteers_controller.rb
index 0a3f9d6fa7..519407c3fc 100644
--- a/app/controllers/volunteers_controller.rb
+++ b/app/controllers/volunteers_controller.rb
@@ -41,7 +41,7 @@ def create
sms_status = deliver_sms_to @volunteer, body_msg
redirect_to edit_volunteer_path(@volunteer), notice: sms_acct_creation_notice("volunteer", sms_status)
else
- render :new
+ render :new, status: :unprocessable_entity
end
end
@@ -58,7 +58,7 @@ def update
@volunteer.filter_old_emails!(@volunteer.email)
redirect_to edit_volunteer_path(@volunteer), notice: notice
else
- render :edit
+ render :edit, status: :unprocessable_entity
end
end
@@ -73,7 +73,7 @@ def activate
redirect_to edit_volunteer_path(@volunteer), notice: "Volunteer was activated. They have been sent an email."
end
else
- render :edit
+ render :edit, status: :unprocessable_entity
end
end
@@ -82,7 +82,7 @@ def deactivate
if @volunteer.deactivate
redirect_to edit_volunteer_path(@volunteer), notice: "Volunteer was deactivated."
else
- render :edit
+ render :edit, status: :unprocessable_entity
end
end
diff --git a/app/models/case_contact.rb b/app/models/case_contact.rb
index 37696fc9f3..643a57a82e 100644
--- a/app/models/case_contact.rb
+++ b/app/models/case_contact.rb
@@ -29,7 +29,7 @@ class CaseContact < ApplicationRecord
# Draft support requires the casa_case to be nil if the contact is in_progress
belongs_to :casa_case, optional: true
validates :casa_case_id, presence: true, if: :active?
- validate :draft_case_ids_not_empty, if: :active_or_details?
+ validate :draft_case_ids_not_empty, unless: :started?
has_many :case_contact_contact_types
has_many :contact_types, through: :case_contact_contact_types
@@ -37,6 +37,8 @@ class CaseContact < ApplicationRecord
has_many :additional_expenses
has_many :contact_topic_answers, dependent: :destroy
+ after_save_commit ::CaseContactMetadataCallback.new
+
# Corresponds to the steps in the controller, so validations for certain columns can happen at those steps.
# These steps must be listed in order and have an html template in case_contacts/form.
FORM_STEPS = %i[details notes expenses].freeze
@@ -233,7 +235,7 @@ def has_casa_case_transitioned
def contact_groups_with_types
hash = Hash.new { |h, k| h[k] = [] }
- contact_types.each do |contact_type|
+ contact_types.includes(:contact_type_group).each do |contact_type|
hash[contact_type.contact_type_group.name] << contact_type.name
end
hash
diff --git a/app/services/case_contact_update_service.rb b/app/services/case_contact_update_service.rb
deleted file mode 100644
index 3b10d18542..0000000000
--- a/app/services/case_contact_update_service.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-class CaseContactUpdateService
- attr_reader :case_contact
-
- def initialize(case_contact)
- @case_contact = case_contact
- end
-
- def update_attrs(new_attrs)
- old_attrs = case_contact.as_json
-
- result = case_contact.update(new_attrs)
- update_status_metadata(old_attrs, new_attrs) if result
-
- result
- end
-
- private
-
- def update_status_metadata(old_attrs, new_attrs)
- return if old_attrs[:status] == new_attrs[:status]
-
- metadata = case_contact.metadata
- metadata["status"] ||= {}
- metadata["status"][new_attrs[:status]] = Time.zone.now
-
- case_contact.update(metadata: metadata)
- end
-end
diff --git a/app/services/deployment/backfill_case_contact_started_metadata_service.rb b/app/services/deployment/backfill_case_contact_started_metadata_service.rb
new file mode 100644
index 0000000000..e193b5e6a2
--- /dev/null
+++ b/app/services/deployment/backfill_case_contact_started_metadata_service.rb
@@ -0,0 +1,12 @@
+module Deployment
+ class BackfillCaseContactStartedMetadataService
+ def backfill_metadata
+ case_contacts = CaseContact.where("metadata->'status' IS NOT NULL AND metadata->'status'->'started' IS NULL")
+
+ case_contacts.each do |case_contact|
+ case_contact.metadata["status"]["started"] = case_contact.created_at.as_json
+ case_contact.save!
+ end
+ end
+ end
+end
diff --git a/app/views/casa_cases/show.html.erb b/app/views/casa_cases/show.html.erb
index d7c04eabb2..cc895bdb95 100644
--- a/app/views/casa_cases/show.html.erb
+++ b/app/views/casa_cases/show.html.erb
@@ -130,14 +130,24 @@
<%= render(partial: "case_contacts/case_contact",
collection: @casa_case.decorate
.case_contacts_ordered_by_occurred_at
- .includes(:contact_types)
+ .includes(
+ :creator,
+ :followups,
+ :contact_types,
+ contact_topic_answers: [:contact_topic]
+ )
.grab_all(current_user),
as: :contact) %>
<% else %>
<%= render(partial: "case_contacts/case_contact",
collection: @casa_case.decorate
.case_contacts_filtered_by_active_assignment_ordered_by_occurred_at
- .includes(:contact_types)
+ .includes(
+ :creator,
+ :followups,
+ :contact_types,
+ contact_topic_answers: [:contact_topic]
+ )
.grab_all(current_user),
as: :contact) %>
<% end %>
diff --git a/app/views/case_contacts/form/expenses.html.erb b/app/views/case_contacts/form/expenses.html.erb
index b1dde6c48a..6b606916dd 100644
--- a/app/views/case_contacts/form/expenses.html.erb
+++ b/app/views/case_contacts/form/expenses.html.erb
@@ -4,6 +4,16 @@
<%= form_with(model: @case_contact, url: wizard_path(nil, case_contact_id: @case_contact.id), local: true, id: "casa-contact-form", class: "component-validated-form") do |form| %>
<%= render "/shared/error_messages", resource: @case_contact %>
+ <% if Flipper.enabled?(:reimbursement_warning, current_organization) %>
+
+ Please note that there is a $35.00 per month cap per volunteer for your mileage.
+ We aim to mail your reimbursement to you via check within 14-28 business days of your request for reimbursement.
+