Skip to content

Commit 3087bcc

Browse files
authored
Merge pull request #5831 from nhsuk/de-dup-schools-on-teams-page
Show team schools and clinics for current academic year
2 parents e26d02b + 9ecc589 commit 3087bcc

3 files changed

Lines changed: 25 additions & 5 deletions

File tree

app/controllers/teams_controller.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
class TeamsController < ApplicationController
44
skip_after_action :verify_policy_scoped
55
before_action :set_team
6+
before_action :set_schools, only: :schools
7+
before_action :set_clinics, only: :clinics
68

79
layout "full"
810

@@ -23,4 +25,24 @@ def clinics
2325
def set_team
2426
@team = authorize current_team
2527
end
28+
29+
def set_schools
30+
@schools =
31+
@team
32+
.schools
33+
.joins(:team_locations)
34+
.where(team_locations: { academic_year: AcademicYear.pending })
35+
.distinct
36+
.order(:name)
37+
end
38+
39+
def set_clinics
40+
@clinics =
41+
@team
42+
.community_clinics
43+
.joins(:team_locations)
44+
.where(team_locations: { academic_year: AcademicYear.pending })
45+
.distinct
46+
.order(:name)
47+
end
2648
end

app/views/teams/clinics.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<% end %>
1919
<% end %>
2020
<% table.with_body do |body| %>
21-
<% @team.community_clinics.each do |clinic| %>
21+
<% @clinics.each do |clinic| %>
2222
<% body.with_row do |row| %>
2323
<% row.with_cell {
2424
[

app/views/teams/schools.html.erb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@
1515
<% table.with_head do |head| %>
1616
<% head.with_row do |row| %>
1717
<% row.with_cell { "Name" } %>
18-
<% row.with_cell { "URN" } %>
19-
<% row.with_cell { "Phase" } %>
18+
<% row.with_cell { "School URN" } %>
2019
<% end %>
2120
<% end %>
2221
<% table.with_body do |body| %>
23-
<% @team.schools.each do |school| %>
22+
<% @schools.each do |school| %>
2423
<% body.with_row do |row| %>
2524
<% row.with_cell {
2625
[
@@ -32,7 +31,6 @@
3231
.html_safe
3332
} %>
3433
<% row.with_cell { tag.span(school.urn_and_site, class: "app-u-code") } %>
35-
<% row.with_cell { school.human_enum_name(:phase) } %>
3634
<% end %>
3735
<% end %>
3836
<% end %>

0 commit comments

Comments
 (0)