Browse Source

f

CLDC-1661-new-page-for-housing-providers
Jack S 2 years ago
parent
commit
4743fb6fba
  1. 7
      app/controllers/organisation_relationships_controller.rb
  2. 8
      app/helpers/navigation_items_helper.rb
  3. 7
      app/views/organisation_relationships/managing_agents.html.erb
  4. 26
      db/seeds.rb

7
app/controllers/organisation_relationships_controller.rb

@ -4,12 +4,9 @@ class OrganisationRelationshipsController < ApplicationController
before_action :authenticate_user!
def managing_agents
# kick out if org isn't the current org
# kick out if cannot access org
@managing_agents = OrganisationRelationships.where(
owning_organisation_id: organisation.id,
relationship_type: :managing,
)
@managing_agents = organisation.managing_agents
end
private

8
app/helpers/navigation_items_helper.rb

@ -2,7 +2,7 @@ module NavigationItemsHelper
NavigationItem = Struct.new(:text, :href, :current, :classes)
def primary_items(path, current_user)
if current_user.support?
items = if current_user.support?
[
NavigationItem.new("Organisations", organisations_path, organisations_current?(path)),
NavigationItem.new("Users", "/users", users_current?(path)),
@ -24,9 +24,11 @@ module NavigationItemsHelper
FeatureToggle.sales_log_enabled? ? NavigationItem.new("Sales logs", sales_logs_path, sales_logs_current?(path)) : nil,
NavigationItem.new("Users", users_organisation_path(current_user.organisation), subnav_users_path?(path)),
NavigationItem.new("About your organisation", "/organisations/#{current_user.organisation.id}", subnav_details_path?(path)),
managing_agents_item,
].compact
end
# figure out correct rules
items << managing_agents_item(path)
end
def secondary_items(path, current_organisation_id)
@ -97,7 +99,7 @@ private
path.include?("/managing-agents")
end
def managing_agents_item
def managing_agents_item(path)
return unless FeatureToggle.managing_agents_enabled?
return unless current_user.organisation.holds_own_stock?

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

@ -1,3 +1,8 @@
<% 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.inspect %>
<%= managing_agent.name %>
<% end %>

26
db/seeds.rb

@ -8,6 +8,17 @@
# rubocop:disable Rails/Output
unless Rails.env.test?
managing_agent = Organisation.find_or_create_by!(
name: "Managing Agent",
address_line1: "2 Marsham Street",
address_line2: "London",
postcode: "SW1P 4DF",
holds_own_stock: true,
other_stock_owners: "None",
managing_agents_label: "None",
provider_type: "LA",
)
org = Organisation.find_or_create_by!(
name: "DLUHC",
address_line1: "2 Marsham Street",
@ -26,19 +37,12 @@ unless Rails.env.test?
end
end
Organisation.find_or_create_by!(
name: "DLUHC",
address_line1: "2 Marsham Street",
address_line2: "London",
postcode: "SW1P 4DF",
holds_own_stock: true,
other_stock_owners: "None",
managing_agents_label: "None",
provider_type: "LA",
child_organisations: [org],
OrganisationRelationship.create!(
child_organisation: org,
parent_organisation: managing_agent,
relationship_type: OrganisationRelationship::MANAGING,
)
if Rails.env.development? && User.count.zero?
User.create!(
name: "Provider",

Loading…
Cancel
Save