|
|
|
@ -8,6 +8,7 @@ class OrganisationsController < ApplicationController
|
|
|
|
|
before_action :authenticate_scope!, except: [:index] |
|
|
|
|
before_action -> { session_filters(specific_org: true) }, if: -> { current_user.support? || current_user.organisation.has_managing_agents? }, only: %i[lettings_logs sales_logs email_lettings_csv download_lettings_csv email_sales_csv download_sales_csv] |
|
|
|
|
before_action :set_session_filters, if: -> { current_user.support? || current_user.organisation.has_managing_agents? }, only: %i[lettings_logs sales_logs email_lettings_csv download_lettings_csv email_sales_csv download_sales_csv] |
|
|
|
|
before_action :log_filter_manager, if: -> { current_user.support? || current_user.organisation.has_managing_agents? }, only: %i[lettings_logs sales_logs email_lettings_csv download_lettings_csv email_sales_csv download_sales_csv] |
|
|
|
|
|
|
|
|
|
def index |
|
|
|
|
redirect_to organisation_path(current_user.organisation) unless current_user.support? |
|
|
|
@ -91,7 +92,7 @@ class OrganisationsController < ApplicationController
|
|
|
|
|
|
|
|
|
|
def lettings_logs |
|
|
|
|
organisation_logs = LettingsLog.visible.where(owning_organisation_id: @organisation.id) |
|
|
|
|
unpaginated_filtered_logs = filtered_logs(organisation_logs, search_term, @session_filters) |
|
|
|
|
unpaginated_filtered_logs = filtered_logs(organisation_logs, search_term, @log_filter_manager.applied_filters) |
|
|
|
|
|
|
|
|
|
respond_to do |format| |
|
|
|
|
format.html do |
|
|
|
@ -107,7 +108,7 @@ class OrganisationsController < ApplicationController
|
|
|
|
|
|
|
|
|
|
def download_lettings_csv |
|
|
|
|
organisation_logs = LettingsLog.visible.where(owning_organisation_id: @organisation.id) |
|
|
|
|
unpaginated_filtered_logs = filtered_logs(organisation_logs, search_term, @session_filters) |
|
|
|
|
unpaginated_filtered_logs = filtered_logs(organisation_logs, search_term, @log_filter_manager.applied_filters) |
|
|
|
|
codes_only = params.require(:codes_only) == "true" |
|
|
|
|
|
|
|
|
|
render "logs/download_csv", locals: { search_term:, count: unpaginated_filtered_logs.size, post_path: lettings_logs_email_csv_organisation_path, codes_only: } |
|
|
|
@ -120,7 +121,7 @@ class OrganisationsController < ApplicationController
|
|
|
|
|
|
|
|
|
|
def sales_logs |
|
|
|
|
organisation_logs = SalesLog.where(owning_organisation_id: @organisation.id) |
|
|
|
|
unpaginated_filtered_logs = filtered_logs(organisation_logs, search_term, @session_filters) |
|
|
|
|
unpaginated_filtered_logs = filtered_logs(organisation_logs, search_term, @log_filter_manager.applied_filters) |
|
|
|
|
|
|
|
|
|
respond_to do |format| |
|
|
|
|
format.html do |
|
|
|
@ -140,7 +141,7 @@ class OrganisationsController < ApplicationController
|
|
|
|
|
|
|
|
|
|
def download_sales_csv |
|
|
|
|
organisation_logs = SalesLog.visible.where(owning_organisation_id: @organisation.id) |
|
|
|
|
unpaginated_filtered_logs = filtered_logs(organisation_logs, search_term, @session_filters) |
|
|
|
|
unpaginated_filtered_logs = filtered_logs(organisation_logs, search_term, @log_filter_manager.applied_filters) |
|
|
|
|
codes_only = params.require(:codes_only) == "true" |
|
|
|
|
|
|
|
|
|
render "logs/download_csv", locals: { search_term:, count: unpaginated_filtered_logs.size, post_path: sales_logs_email_csv_organisation_path, codes_only: } |
|
|
|
@ -157,6 +158,10 @@ class OrganisationsController < ApplicationController
|
|
|
|
|
|
|
|
|
|
private |
|
|
|
|
|
|
|
|
|
def log_filter_manager |
|
|
|
|
@log_filter_manager = LogsFilterManager.new(@session_filters, current_user) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def org_params |
|
|
|
|
params.require(:organisation).permit(:name, :address_line1, :address_line2, :postcode, :phone, :holds_own_stock, :provider_type, :housing_registration_no) |
|
|
|
|
end |
|
|
|
|