Browse Source

feat: add target org helper

pull/957/head
natdeanlewissoftwire 3 years ago
parent
commit
9c78e4ba38
  1. 8
      app/controllers/organisation_relationships_controller.rb
  2. 4
      app/views/organisation_relationships/remove_housing_provider.html.erb
  3. 4
      db/schema.rb

8
app/controllers/organisation_relationships_controller.rb

@ -83,9 +83,9 @@ class OrganisationRelationshipsController < ApplicationController
end end
def delete_housing_provider def delete_housing_provider
organisation_relationship_to_remove = OrganisationRelationship.find_by!(child_organisation_id: @organisation.id, parent_organisation_id: target_organisation_id, relationship_type: OrganisationRelationship::OWNING) organisation_relationship_to_remove = OrganisationRelationship.find_by!(child_organisation: @organisation, parent_organisation: target_organisation, relationship_type: OrganisationRelationship::OWNING)
organisation_relationship_to_remove.destroy! organisation_relationship_to_remove.destroy!
flash[:notice] = "#{Organisation.find(target_organisation_id).name} is no longer one of #{current_user.data_coordinator? ? 'your' : "this organisation's"} housing providers" flash[:notice] = "#{target_organisation.name} is no longer one of #{current_user.data_coordinator? ? 'your' : "this organisation's"} housing providers"
redirect_to housing_providers_organisation_path redirect_to housing_providers_organisation_path
end end
@ -104,8 +104,8 @@ private
params["organisation"]["related_organisation_id"] params["organisation"]["related_organisation_id"]
end end
def target_organisation_id def target_organisation
params["target_organisation_id"] @target_organisation ||= Organisation.find(params[:target_organisation_id])
end end
def search_term def search_term

4
app/views/organisation_relationships/remove_housing_provider.html.erb

@ -1,10 +1,10 @@
<%= form_with url: housing_providers_organisation_path(target_organisation_id: @target_organisation_id), method: "delete", local: true do |f| %> <%= form_with url: housing_providers_organisation_path(target_organisation: @target_organisation), method: "delete", local: true do |f| %>
<% if current_user.support? %> <% if current_user.support? %>
<%= render partial: "organisations/headings", locals: { main: @organisation.name, sub: nil } %> <%= render partial: "organisations/headings", locals: { main: @organisation.name, sub: nil } %>
<%= render SubNavigationComponent.new(items: secondary_items(request.path, @organisation.id)) %> <%= render SubNavigationComponent.new(items: secondary_items(request.path, @organisation.id)) %>
<h2 class="govuk-visually-hidden">Remove Housing Provider</h2> <h2 class="govuk-visually-hidden">Remove Housing Provider</h2>
<% end %> <% end %>
<% @housing_provider = Organisation.find(@target_organisation_id) %> <% @housing_provider = @target_organisation %>
<% if current_user.support? %> <% if current_user.support? %>
<%= govuk_back_link(href: :back) %> <%= govuk_back_link(href: :back) %>
<%= render partial: "organisations/headings", locals: { main: "You are removing ‘#{@housing_provider.name}’ from this organisation's housing providers", sub: nil } %> <%= render partial: "organisations/headings", locals: { main: "You are removing ‘#{@housing_provider.name}’ from this organisation's housing providers", sub: nil } %>

4
db/schema.rb

@ -359,8 +359,6 @@ ActiveRecord::Schema[7.0].define(version: 2022_10_19_082625) do
t.integer "hholdcount" t.integer "hholdcount"
t.integer "age3" t.integer "age3"
t.integer "age3_known" t.integer "age3_known"
t.integer "income1"
t.integer "income1nk"
t.integer "age4" t.integer "age4"
t.integer "age4_known" t.integer "age4_known"
t.integer "age5" t.integer "age5"
@ -369,6 +367,8 @@ ActiveRecord::Schema[7.0].define(version: 2022_10_19_082625) do
t.integer "age6_known" t.integer "age6_known"
t.string "la" t.string "la"
t.integer "la_known" t.integer "la_known"
t.integer "income1"
t.integer "income1nk"
t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id" t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id"
t.index ["managing_organisation_id"], name: "index_sales_logs_on_managing_organisation_id" t.index ["managing_organisation_id"], name: "index_sales_logs_on_managing_organisation_id"
t.index ["owning_organisation_id"], name: "index_sales_logs_on_owning_organisation_id" t.index ["owning_organisation_id"], name: "index_sales_logs_on_owning_organisation_id"

Loading…
Cancel
Save