diff --git a/app/controllers/housing_providers_controller.rb b/app/controllers/housing_providers_controller.rb index c75c35f03..edfe40ff2 100644 --- a/app/controllers/housing_providers_controller.rb +++ b/app/controllers/housing_providers_controller.rb @@ -4,9 +4,9 @@ class HousingProvidersController < ApplicationController def index housing_providers = - Organisation.joins(:parent_organisations) + Organisation.joins(:child_organisations) .where(organisation_relationships: { - parent_organisation_id: current_user.organisation_id, + child_organisation_id: current_user.organisation_id, relationship_type: OrganisationRelationship.relationship_types[:owning], }) .order(:name) diff --git a/app/controllers/organisations_controller.rb b/app/controllers/organisations_controller.rb index 849ea7015..1d00dd31b 100644 --- a/app/controllers/organisations_controller.rb +++ b/app/controllers/organisations_controller.rb @@ -137,9 +137,9 @@ class OrganisationsController < ApplicationController def housing_providers housing_providers = - Organisation.joins(:parent_organisations) + Organisation.joins(:child_organisations) .where(organisation_relationships: { - parent_organisation_id: current_user.organisation_id, + child_organisation_id: @organisation.id, relationship_type: OrganisationRelationship.relationship_types[:owning], }) .order(:name) diff --git a/app/views/housing_providers/_housing_provider_list.html.erb b/app/views/housing_providers/_housing_provider_list.html.erb index 998d7f808..68a40c16b 100644 --- a/app/views/housing_providers/_housing_provider_list.html.erb +++ b/app/views/housing_providers/_housing_provider_list.html.erb @@ -7,10 +7,12 @@ <%= table.body do |body| %> <%= body.row do |row| %> <% row.cell(text: organisation.name) %> - <% row.cell(html_attributes: { - scope: "row", - }) do %> - <%= govuk_link_to("Remove", "housing-providers/#{organisation.id}") %> + <% if current_user.data_coordinator? || current_user.support? %> + <% row.cell(html_attributes: { + scope: "row", + }) do %> + <%= govuk_link_to("Remove", "housing-providers/#{organisation.id}") %> + <% end %> <% end %> <% end %> <% end %>