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

FFS-2408: Rename site_id to client_agency_id #446

Merged
merged 12 commits into from
Feb 12, 2025
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,21 +109,21 @@ $ i18n-tasks remove-unused # removes unused keys across locale files

For more information on usage and helpful rake tasks to manage locale files, see [the documentation](https://github.com/glebm/i18n-tasks#usage).

## "Site-specific" translations
## "Client Agency-specific" translations

The CBV pilot project is architected to be multi-tenant across jurisdictions we
are actively piloting with. Each jurisdiction's agency is configured as a
"site" in app/config/site-config.yml and has a short "id", e.g. "nyc", "ma",
"client agency" in app/config/client-agency-config.yml and has a short "id", e.g. "nyc", "ma",
and "sandbox".

We often need to adjust copy specific to each site. The preferred way to do it
is by using the `site_translation` helper, which wraps Rails's `t` view helper
and looks for the current site's "id" as a sub-key of the given prefix.
We often need to adjust copy specific to each client agency. The preferred way to do it
is by using the `client_agency_translation` helper, which wraps Rails's `t` view helper
and looks for the current client agency's "id" as a sub-key of the given prefix.

Usage:

```erb
<%= site_translation(".learn_more_html") %>
<%= client_agency_translation(".learn_more_html") %>
```

And the corresponding locale file:
Expand Down Expand Up @@ -214,7 +214,7 @@ If you're new to CBV, here's a summary of how to get started navigating the app.
1. Search for your employer. When you select one, the local page will show you some fake credentials at the very bottom of the screen. Use these to sign in.
1. Finally, you should be able to complete the applicant flow, including looking at the PDF.
1. To complete the caseworker flow, add `?is_caseworker=true` to the /cbv/summary.pdf path to see the PDF that gets sent (it's different from the one we send the applicant!)
1. Note: You can switch to a different pilot partner (state) by going to the irb prompt and running `CbvFlow.last.update(site_id: 'ma')`. Right now you can only pass it `ma` or `nyc`.
1. Note: You can switch to a different pilot partner (state) by going to the irb prompt and running `CbvFlow.last.update(client_agency_id: 'ma')`. Right now you can only pass it `ma` or `nyc`.

## Pa11y Scan

Expand Down
6 changes: 3 additions & 3 deletions app/app/controllers/api/invitations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ def cbv_flow_invitation_params
:agency_id_number,
:beacon_id,
:user_id,
:site_id
:client_agency_id
)
end

def site_id
cbv_flow_invitation_params[:site_id]
def client_agency_id
cbv_flow_invitation_params[:client_agency_id]
end

private
Expand Down
20 changes: 10 additions & 10 deletions app/app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class ApplicationController < ActionController::Base
helper :view
helper_method :current_site, :show_translate_button?, :show_menu?
helper_method :current_agency, :show_translate_button?, :show_menu?
around_action :switch_locale
before_action :add_newrelic_metadata
before_action :redirect_if_maintenance_mode
Expand All @@ -12,11 +12,11 @@ class ApplicationController < ActionController::Base
end

def after_sign_in_path_for(user)
caseworker_dashboard_path(site_id: user.site_id)
caseworker_dashboard_path(client_agency_id: user.client_agency_id)
end

def after_sign_out_path_for(resource_or_scope)
new_user_session_path(site_id: params[:site_id])
new_user_session_path(client_agency_id: params[:client_agency_id])
end

def switch_locale(&action)
Expand All @@ -25,8 +25,8 @@ def switch_locale(&action)
I18n.with_locale(locale, &action)
end

def site_config
Rails.application.config.sites
def agency_config
Rails.application.config.client_agencies
end

private
Expand All @@ -45,8 +45,8 @@ def home_page?
request.path == root_path
end

def current_site
@current_site ||= site_config[params[:site_id]]
def current_agency
@current_agency ||= agency_config[params[:client_agency_id]]
end

def enable_mini_profiler_in_demo
Expand All @@ -62,7 +62,7 @@ def demo_mode?
protected

def pinwheel_for(cbv_flow)
environment = site_config[cbv_flow.site_id].pinwheel_environment
environment = agency_config[cbv_flow.client_agency_id].pinwheel_environment

PinwheelService.new(environment)
end
Expand All @@ -71,7 +71,7 @@ def add_newrelic_metadata
attributes = {
cbv_flow_id: session[:cbv_flow_id],
session_id: session.id.to_s,
site_id: params[:site_id],
client_agency_id: params[:client_agency_id],
locale: params[:locale],
user_id: current_user.try(:id)
}
Expand Down Expand Up @@ -99,4 +99,4 @@ def check_help_param
)
end
end
end
end
4 changes: 2 additions & 2 deletions app/app/controllers/caseworker/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ class Caseworker::BaseController < ApplicationController
def authenticate_user!
super

unless current_user.site_id == params[:site_id]
unless current_user.client_agency_id == params[:client_agency_id]
redirect_to root_url, flash: {
slim_alert: { message: t("shared.error_unauthorized"), type: "error" }
}
end
end

def redirect_if_disabled
unless current_site.staff_portal_enabled
unless current_agency.staff_portal_enabled
redirect_to root_url, flash: {
slim_alert: { message: I18n.t("caseworker.entries.disabled"), type: "error" }
}
Expand Down
26 changes: 13 additions & 13 deletions app/app/controllers/caseworker/cbv_flow_invitations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ class Caseworker::CbvFlowInvitationsController < Caseworker::BaseController
helper_method :language_options

def new
@site_id = site_id
@cbv_flow_invitation = CbvFlowInvitation.new(site_id: site_id)
@client_agency_id = client_agency_id
@cbv_flow_invitation = CbvFlowInvitation.new(client_agency_id: client_agency_id)

if @site_id == "ma"
if @client_agency_id == "ma"
@cbv_flow_invitation.snap_application_date ||= Date.today
end
end

def create
invitation_params = base_params.merge(site_specific_params)
invitation_params = base_params.merge(client_agency_specific_params)
# handle errors from the mail service
begin
@cbv_flow_invitation = CbvInvitationService.new(event_logger).invite(
Expand All @@ -27,7 +27,7 @@ def create
flash[:alert] = t(".invite_failed",
email_address: cbv_flow_invitation_params[:email_address],
error_message: e.message)
return redirect_to caseworker_dashboard_path(site_id: params[:site_id])
return redirect_to caseworker_dashboard_path(client_agency_id: params[:client_agency_id])
end

if @cbv_flow_invitation.errors.any?
Expand All @@ -51,7 +51,7 @@ def create
message: t(".invite_success", email_address: cbv_flow_invitation_params[:email_address]),
type: "success"
}
redirect_to caseworker_dashboard_path(site_id: params[:site_id])
redirect_to caseworker_dashboard_path(client_agency_id: params[:client_agency_id])
end

private
Expand All @@ -63,8 +63,8 @@ def language_options
end

def ensure_valid_params!
if site_config.site_ids.exclude?(site_id)
flash[:alert] = t("caseworker.cbv_flow_invitations.incorrect_site_id")
if agency_config.client_agency_ids.exclude?(client_agency_id)
flash[:alert] = t("caseworker.cbv_flow_invitations.incorrect_client_agency_id")
redirect_to root_url
end
end
Expand All @@ -77,11 +77,11 @@ def base_params
:last_name,
:email_address,
:snap_application_date,
).merge(site_id: site_id)
).merge(client_agency_id: client_agency_id)
end

def site_specific_params
case site_id
def client_agency_specific_params
case client_agency_id
when "ma"
cbv_flow_invitation_params.slice(:agency_id_number, :beacon_id)
when "nyc"
Expand All @@ -106,7 +106,7 @@ def cbv_flow_invitation_params
)
end

def site_id
params[:site_id]
def client_agency_id
params[:client_agency_id]
end
end
2 changes: 1 addition & 1 deletion app/app/controllers/caseworker/entries_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class Caseworker::EntriesController < Caseworker::BaseController
def index
@current_site = current_site
@current_agency = current_agency
end
end
42 changes: 21 additions & 21 deletions app/app/controllers/cbv/base_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class Cbv::BaseController < ApplicationController
before_action :set_cbv_flow, :ensure_cbv_flow_not_yet_complete, :prevent_back_after_complete, :capture_page_view
helper_method :agency_url, :next_path, :get_comment_by_account_id, :current_site
helper_method :agency_url, :next_path, :get_comment_by_account_id, :current_agency

private

Expand All @@ -16,10 +16,10 @@ def set_cbv_flow
end
if invitation.expired?
track_expired_event(invitation)
return redirect_to(cbv_flow_expired_invitation_path(site_id: invitation.site_id))
return redirect_to(cbv_flow_expired_invitation_path(client_agency_id: invitation.client_agency_id))
end
if invitation.complete?
return redirect_to(cbv_flow_expired_invitation_path(site_id: invitation.site_id))
return redirect_to(cbv_flow_expired_invitation_path(client_agency_id: invitation.client_agency_id))
end

@cbv_flow = CbvFlow.create_from_invitation(invitation)
Expand All @@ -44,26 +44,26 @@ def ensure_cbv_flow_not_yet_complete
redirect_to(cbv_flow_success_path)
end

def current_site
return unless @cbv_flow.present? && @cbv_flow.site_id.present?
def current_agency
return unless @cbv_flow.present? && @cbv_flow.client_agency_id.present?

@current_site ||= site_config[@cbv_flow.site_id]
@current_site ||= agency_config[@cbv_flow.client_agency_id]
end

def next_path
case params[:controller]
when "cbv/entries"
cbv_flow_employer_search_path
when "cbv/employer_searches"
cbv_flow_synchronizations_path
when "cbv/synchronizations"
cbv_flow_payment_details_path
when "cbv/missing_results"
cbv_flow_summary_path
when "cbv/payment_details"
cbv_flow_add_job_path
when "cbv/summaries"
cbv_flow_success_path
when "cbv/entries"
cbv_flow_employer_search_path
when "cbv/employer_searches"
cbv_flow_synchronizations_path
when "cbv/synchronizations"
cbv_flow_payment_details_path
when "cbv/missing_results"
cbv_flow_summary_path
when "cbv/payment_details"
cbv_flow_add_job_path
when "cbv/summaries"
cbv_flow_success_path
end
end

Expand All @@ -72,7 +72,7 @@ def pinwheel
end

def agency_url
current_site&.agency_contact_website
current_agency&.agency_contact_website
end

def get_comment_by_account_id(account_id)
Expand All @@ -90,7 +90,7 @@ def capture_page_view
event_logger.track("CbvPageView", request, {
cbv_flow_id: @cbv_flow.id,
invitation_id: @cbv_flow.cbv_flow_invitation_id,
site_id: @cbv_flow.site_id,
client_agency_id: @cbv_flow.client_agency_id,
path: request.path
})
rescue => ex
Expand Down Expand Up @@ -121,7 +121,7 @@ def track_invitation_clicked_event(invitation, cbv_flow)
timestamp: Time.now.to_i,
invitation_id: invitation.id,
cbv_flow_id: cbv_flow.id,
site_id: cbv_flow.site_id,
client_agency_id: cbv_flow.client_agency_id,
seconds_since_invitation: (Time.now - invitation.created_at).to_i
})
rescue => ex
Expand Down
4 changes: 2 additions & 2 deletions app/app/controllers/cbv/entries_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class Cbv::EntriesController < Cbv::BaseController
def show
event_logger.track("ApplicantViewedAgreement", request, {
timestamp: Time.now.to_i,
site_id: @cbv_flow.site_id,
client_agency_id: @cbv_flow.client_agency_id,
cbv_flow_id: @cbv_flow.id,
invitation_id: @cbv_flow.cbv_flow_invitation_id
})
Expand All @@ -12,7 +12,7 @@ def create
if params["agreement"] == "1"
event_logger.track("ApplicantAgreed", request, {
timestamp: Time.now.to_i,
site_id: @cbv_flow.site_id,
client_agency_id: @cbv_flow.client_agency_id,
cbv_flow_id: @cbv_flow.id,
invitation_id: @cbv_flow.cbv_flow_invitation_id
})
Expand Down
8 changes: 4 additions & 4 deletions app/app/controllers/cbv/expired_invitations_controller.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
class Cbv::ExpiredInvitationsController < Cbv::BaseController
skip_before_action :set_cbv_flow, :ensure_cbv_flow_not_yet_complete
helper_method :current_site
helper_method :current_agency

def show
end

private

def current_site
return unless Rails.application.config.sites.site_ids.include?(params[:site_id])
def current_agency
return unless Rails.application.config.client_agencies.client_agency_ids.include?(params[:client_agency_id])

Rails.application.config.sites[params[:site_id]]
Rails.application.config.client_agencies[params[:client_agency_id]]
end
end
Loading
Loading