Skip to content

Commit

Permalink
Refactor placement routes to include provider id
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamie committed Oct 3, 2024
1 parent 0d775cb commit 6edaabb
Show file tree
Hide file tree
Showing 31 changed files with 169 additions and 152 deletions.
2 changes: 1 addition & 1 deletion app/components/placement/summary_component.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<li class="app-search-results__item">
<h2 class="app-search-result__item-title">
<%= govuk_link_to(placements_placement_path(placement), no_visited_state: true) do %>
<%= govuk_link_to(placements_provider_placement_path(provider, placement), no_visited_state: true) do %>
<span><%= school.name %></span>
<br>
<span><%= placement.title %></span>
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/placements/organisations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def landing_page_path(organisation)
if organisation.is_a?(School)
placements_school_placements_path(organisation)
else # Provider
placements_placements_path
placements_provider_placements_path(organisation)
end
end
end
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class Placements::PlacementsController < Placements::ApplicationController
before_action :set_current_organisation
class Placements::Providers::PlacementsController < Placements::ApplicationController
before_action :set_current_provider
helper_method :filter_form, :location_coordinates

def index
Expand Down Expand Up @@ -30,14 +30,12 @@ def schools_scope
end
end

def set_current_organisation
return redirect_to organisations_path if current_user.current_organisation.blank?

@provider = current_user.current_organisation
def set_current_provider
@provider = current_user.providers.find(params[:provider_id])
end

def filter_form
@filter_form ||= Placements::Placements::FilterForm.new(filter_params)
@filter_form ||= Placements::Placements::FilterForm.new(@provider, filter_params)
end

def search_location
Expand Down
11 changes: 8 additions & 3 deletions app/forms/placements/placements/filter_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ class Placements::Placements::FilterForm < ApplicationForm
attribute :academic_year_id, default: Placements::AcademicYear.current.id
attribute :only_partner_schools, :boolean, default: false

def initialize(params = {})
def initialize(provider, params = {})
@provider = provider
params.each_value { |v| v.compact_blank! if v.is_a?(Array) }

super(params)
Expand All @@ -20,7 +21,10 @@ def filters_selected?
end

def clear_filters_path(search_location: nil)
placements_placements_path(search_location:, filters: { placements_to_show:, academic_year_id: })
placements_provider_placements_path(
@provider,
search_location:, filters: { placements_to_show:, academic_year_id: },
)
end

def index_path_without_filter(filter:, value: nil, search_location: nil)
Expand All @@ -30,7 +34,8 @@ def index_path_without_filter(filter:, value: nil, search_location: nil)
compacted_attributes.merge(filter => compacted_attributes[filter].reject { |filter_value| filter_value == value })
end

placements_placements_path(
placements_provider_placements_path(
@provider,
params: { filters: without_filter, search_location: },
)
end
Expand Down
4 changes: 2 additions & 2 deletions app/mailers/user_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def partnership_destroyed_notification(user, source_organisation, partner_organi
end

def placement_provider_assigned_notification(user, provider, placement)
placement_link = placements_placement_url(placement)
placement_link = placements_provider_placement_url(provider, placement)
school = placement.school

notify_email(
Expand All @@ -124,7 +124,7 @@ def placement_provider_assigned_notification(user, provider, placement)
end

def placement_provider_removed_notification(user, provider, placement)
placement_link = placements_placement_url(placement)
placement_link = placements_provider_placement_url(provider, placement)
school = placement.school

notify_email(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<%= content_for(:primary_navigation_content) do %>
<%= render PrimaryNavigationComponent.new do |component| %>
<% component.with_navigation_item t(".placements"), placements_placements_path, current: current_navigation == :placements %>
<% component.with_navigation_item t(".placements"), placements_provider_placements_path(provider), current: current_navigation == :placements %>
<% component.with_navigation_item t(".partner_schools"), placements_provider_partner_schools_path(provider), current: current_navigation == :partner_schools %>
<% component.with_navigation_item t(".users"), placements_provider_users_path(provider), current: current_navigation == :users %>
<% component.with_navigation_item t(".organisation_details"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<ul class="govuk-list govuk-list--bullet">
<% @partner_school.partner_provider_placements(provider).each do |placement| %>
<li>
<%= govuk_link_to(placement.title, placements_placement_path(placement), target: "_blank", new_tab: true, no_visited_state: true) %>
<%= govuk_link_to(placement.title, placements_provider_placement_path(provider, placement), target: "_blank", new_tab: true, no_visited_state: true) %>
</li>
<% end %>
</ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
<% end %>

<div class="govuk-width-container">
<%= render "placements/placements/placement_details", school: @placement.school, placement: @placement %>
<%= render "shared/placements/placement_details", school: @placement.school, placement: @placement %>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
<%= form_with(
model: filter_form,
scope: :filters,
url: placements_placements_path,
url: placements_provider_placements_path(@provider),
method: "get",
) do |form| %>
<%= form.govuk_submit t("apply_filters") %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
<div class="govuk-grid-column-two-thirds">
<h2 class="govuk-heading-m"><%= t(".enter_a_location") %></h2>
<%= render partial: "shared/search_form", locals: {
url: placements_placements_path,
url: placements_provider_placements_path(@provider),
label: { hidden: true },
caption: { text: t(".location_search_example") },
name: :search_location,
clear_search_url: placements_placements_path(filters: filter_form.attributes),
clear_search_url: placements_provider_placements_path(@provider, filters: filter_form.attributes),
filters: filter_form.attributes,
value: @search_location,
} %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
<% end %>

<div class="govuk-width-container">
<%= render "placement_details", school: @school, placement: @placement %>
<%= render "shared/placements/placement_details", school: @school, placement: @placement %>
</div>
2 changes: 1 addition & 1 deletion app/views/placements/schools/placements/preview.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
<%= render(GovukComponent::NotificationBannerComponent.new(title_text: t(".important"))) do |nb|
nb.with_heading(text: t(".this_is_a_preview"))
end %>
<%= render "placements/placements/placement_details", school: @placement.school, placement: @placement %>
<%= render "shared/placements/placement_details", school: @placement.school, placement: @placement %>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<%= form_for(preview_placement_step, url: current_step_path, method: :put) do |f| %>
<%= f.govuk_error_summary %>
<%= render "placements/placements/placement_details", school: @wizard.school.decorate, placement: preview_placement_step.placement.decorate %>
<%= render "shared/placements/placement_details", school: @wizard.school.decorate, placement: preview_placement_step.placement.decorate %>

<div class="govuk-button-group">
<%= f.govuk_submit t(".publish_placement") %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<h2 class="govuk-heading-m govuk-!-margin-top-0">
<%= t(".itt_placement_dates") %>
</h2>
<%= render "placements/placements/placement_dates", school:, placement: %>
<%= render "shared/placements/placement_dates", school:, placement: %>

<h2 class="govuk-heading-m govuk-!-margin-top-0">
<%= t(".itt_placement_contact") %>
Expand All @@ -28,6 +28,6 @@
<h2 class="govuk-heading-m govuk-!-margin-top-0">
<%= t(".additional_details") %>
</h2>
<%= render "placements/placements/school_details", school:, placement: %>
<%= render "shared/placements/school_details", school:, placement: %>
</div>
</div>
58 changes: 0 additions & 58 deletions config/locales/en/placements/placements.yml

This file was deleted.

39 changes: 39 additions & 0 deletions config/locales/en/placements/providers/placements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
en:
placements:
academic_year:
current_academic_year: This academic year (%{academic_year})
next_academic_year: Next academic year (%{academic_year})
previous_academic_year: Previous academic year (%{academic_year})
providers:
placements:
index:
placements_found:
zero: No placements found
one: 1 placement found
other: "%{count} placements found"
placements: Placements
no_results: There are no placements that match your selection. Try searching again, or removing one or more filters.
enter_a_location: Enter a location
location_search_example: For example, Sunderland or SR2
filter:
partner_schools: Partner schools
terms: Expected date
only_show_partner_schools: Only show placements offered by my partner schools
school: School
subject: Subject
school_phase: School phase
establishment_group: Establishment group
gender: Gender
religious_character: Religious character
ofsted_rating: Ofsted rating
placements_to_show_title: Placements to show
placements_to_show:
available_placements: Available placements
assigned_to_me: Assigned to me
all_placements: All placements
year_group: Primary year group
academic_year:
label: Academic year
show:
page_title: "%{subject_name} - Placements - %{school_name}"
placement: "Placement - %{school_name}"
6 changes: 6 additions & 0 deletions config/locales/en/shared/placements/placement_dates.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
en:
shared:
placements:
placement_dates:
academic_year: Academic year
terms: Expected date
10 changes: 10 additions & 0 deletions config/locales/en/shared/placements/placement_details.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
en:
shared:
placements:
placement_details:
contact_details: Contact details
itt_placement_contact: Placement contact
itt_placement_dates: Placement dates
location: Location
additional_details: Additional details
placement: "Placement - %{school_name}"
14 changes: 14 additions & 0 deletions config/locales/en/shared/placements/school_details.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
en:
shared:
placements:
school_details:
establishment_group: Establishment group
school_phase: School phase
gender: Gender
age_range: Age range
religious_character: Religious character
urban_or_rural: Urban or rural
admissions_policy: Admissions policy
percentage_free_school_meals: Percentage free school meals
ofsted_rating: Ofsted rating

4 changes: 2 additions & 2 deletions config/routes/placements.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@
resources :placements, only: %i[index show]
end
end

resources :placements, only: %i[index show]
end
end

resources :placements, only: %i[index show]
end
Loading

0 comments on commit 6edaabb

Please sign in to comment.