Submit social housing lettings and sales data (CORE)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.4 KiB

class OrganisationRelationshipsController < ApplicationController
include Pagy::Backend
include Modules::SearchFilter
before_action :authenticate_user!
before_action :authenticate_scope!
def housing_providers
housing_providers = organisation.housing_providers
unpaginated_filtered_housing_providers = filtered_collection(housing_providers, search_term)
respond_to do |format|
format.html do
@pagy, @housing_providers = pagy(unpaginated_filtered_housing_providers)
@searched = search_term.presence
@total_count = housing_providers.size
render "organisation_relationships/housing_providers", layout: "application"
end
end
end
def managing_agents
managing_agents = organisation.managing_agents
unpaginated_filtered_managing_agents = filtered_collection(managing_agents, search_term)
respond_to do |format|
format.html do
@pagy, @managing_agents = pagy(unpaginated_filtered_managing_agents)
@searched = search_term.presence
@total_count = managing_agents.size
render "organisation_relationships/managing_agents", layout: "application"
end
end
end
private
def organisation
@organisation ||= Organisation.find(params[:id])
end
def search_term
params["search"]
end
def authenticate_scope!
if current_user.organisation != organisation
render_not_found
end
end
end