Browse Source

feat: remove changes from jack's branch that don't affect mine

CLDC-1661-new-page-for-housing-providers
natdeanlewissoftwire 3 years ago
parent
commit
0bdc4b8c04
  1. 6
      app/controllers/organisation_relationships_controller.rb
  2. 2
      app/helpers/housing_providers_helper.rb
  3. 15
      app/helpers/navigation_items_helper.rb
  4. 2
      app/models/organisation.rb
  5. 8
      app/views/organisation_relationships/managing_agents.html.erb
  6. 4
      db/migrate/20221018143607_rename_organisations_agents_column.rb
  7. 10
      db/seeds.rb

6
app/controllers/organisation_relationships_controller.rb

@ -3,12 +3,6 @@ class OrganisationRelationshipsController < ApplicationController
before_action :authenticate_user! before_action :authenticate_user!
def managing_agents
# kick out if cannot access org
@managing_agents = organisation.managing_agents
end
def housing_providers def housing_providers
@housing_providers = organisation.housing_providers @housing_providers = organisation.housing_providers
end end

2
app/helpers/housing_providers_helper.rb

@ -1,2 +0,0 @@
module HousingProvidersHelper
end

15
app/helpers/navigation_items_helper.rb

@ -103,19 +103,4 @@ private
def subnav_details_path?(path) def subnav_details_path?(path)
path.include?("/organisations") && path.include?("/details") path.include?("/organisations") && path.include?("/details")
end end
def managing_agents_path?(path)
path.include?("/managing-agents")
end
def managing_agents_item(path)
return unless FeatureToggle.managing_agents_enabled?
return unless current_user.organisation.holds_own_stock?
NavigationItem.new(
"Managing agents",
"/organisations/#{current_user.organisation.id}/managing-agents",
managing_agents_path?(path),
)
end
end end

2
app/models/organisation.rb

@ -13,8 +13,6 @@ class Organisation < ApplicationRecord
has_many :child_organisation_relationships, foreign_key: :parent_organisation_id, class_name: "OrganisationRelationship" has_many :child_organisation_relationships, foreign_key: :parent_organisation_id, class_name: "OrganisationRelationship"
has_many :child_organisations, through: :child_organisation_relationships has_many :child_organisations, through: :child_organisation_relationships
has_many :managing_agent_relationships, -> { where(relationship_type: OrganisationRelationship::MANAGING) }, foreign_key: :child_organisation_id, class_name: "OrganisationRelationship"
has_many :managing_agents, through: :managing_agent_relationships, source: :parent_organisation
has_many :housing_provider_relationships, -> { where(relationship_type: OrganisationRelationship::OWNING) }, foreign_key: :child_organisation_id, class_name: "OrganisationRelationship" has_many :housing_provider_relationships, -> { where(relationship_type: OrganisationRelationship::OWNING) }, foreign_key: :child_organisation_id, class_name: "OrganisationRelationship"
has_many :housing_providers, through: :housing_provider_relationships, source: :parent_organisation has_many :housing_providers, through: :housing_provider_relationships, source: :parent_organisation

8
app/views/organisation_relationships/managing_agents.html.erb

@ -1,8 +0,0 @@
<% title = format_title(nil, current_user.support? ? "About this organisation" : "Your managing agents", current_user, nil, nil, @organisation.name) %>
<% content_for :title, title %>
<%= render partial: "organisations/headings", locals: { main: "Your managing agents", sub: nil } %>
<% @managing_agents.each do |managing_agent|%>
<%= managing_agent.name %>
<% end %>

4
db/migrate/20221018143607_rename_organisations_agents_column.rb

@ -1,4 +0,0 @@
class RenameOrganisationsAgentsColumn < ActiveRecord::Migration[7.0]
def change
end
end

10
db/seeds.rb

@ -8,8 +8,8 @@
# rubocop:disable Rails/Output # rubocop:disable Rails/Output
unless Rails.env.test? unless Rails.env.test?
managing_agent = Organisation.find_or_create_by!( housing_provider = Organisation.find_or_create_by!(
name: "Managing Agent", name: "Housing Provider",
address_line1: "2 Marsham Street", address_line1: "2 Marsham Street",
address_line2: "London", address_line2: "London",
postcode: "SW1P 4DF", postcode: "SW1P 4DF",
@ -24,7 +24,7 @@ unless Rails.env.test?
address_line1: "2 Marsham Street", address_line1: "2 Marsham Street",
address_line2: "London", address_line2: "London",
postcode: "SW1P 4DF", postcode: "SW1P 4DF",
holds_own_stock: true, holds_own_stock: false,
other_stock_owners: "None", other_stock_owners: "None",
managing_agents_label: "None", managing_agents_label: "None",
provider_type: "LA", provider_type: "LA",
@ -39,8 +39,8 @@ unless Rails.env.test?
OrganisationRelationship.create!( OrganisationRelationship.create!(
child_organisation: org, child_organisation: org,
parent_organisation: managing_agent, parent_organisation: housing_provider,
relationship_type: OrganisationRelationship::MANAGING, relationship_type: OrganisationRelationship::OWNING,
) )
if Rails.env.development? && User.count.zero? if Rails.env.development? && User.count.zero?

Loading…
Cancel
Save