Browse Source

sales logs are now working

CLDC-1324-remove-not-started-status-no-rebase
JG 2 years ago
parent
commit
624f33389b
  1. 17
      app/controllers/form_controller.rb
  2. 2
      app/controllers/logs_controller.rb
  3. 2
      app/helpers/tasklist_helper.rb

17
app/controllers/form_controller.rb

@ -131,21 +131,25 @@ private
end
end
def find_resource
@log = if new_log_request? || new_log_request_referrer?
@log = if params.key?("sales_log")
if new_log_request? || new_log_request_referrer?
SalesLog.new(owning_organisation: current_user.support? ? nil : current_user.organisation)
else
current_user.sales_logs.find_by(id: params[:id])
end
elsif new_log_request? || new_log_request_referrer?
LettingsLog.new(owning_organisation: current_user.support? ? nil : current_user.organisation)
else
params.key?("sales_log") ? current_user.sales_logs.find_by(id: params[:id]) : current_user.lettings_logs.find_by(id: params[:id])
current_user.lettings_logs.find_by(id: params[:id])
end
end
def find_resource_by_named_id
@log = if params[:sales_log_id].present?
current_user.sales_logs.find_by(id: params[:sales_log_id])
else
if new_log_request?
if request.path.include? ("sales-logs")
elsif new_log_request?
if request.path.include?("sales-logs")
SalesLog.new
else
LettingsLog.new
@ -154,7 +158,6 @@ private
current_user.lettings_logs.find_by(id: params[:lettings_log_id])
end
end
end
def new_log_request?
request.path.split("/").include?("new")

2
app/controllers/logs_controller.rb

@ -15,7 +15,7 @@ private
respond_to do |format|
format.html do
redirect_to ( request.path.include?("sales") ? new_log_sales_logs_path : new_log_lettings_logs_path)
redirect_to(request.path.include?("sales") ? new_log_sales_logs_path : new_log_lettings_logs_path)
end
format.json do
if log.save

2
app/helpers/tasklist_helper.rb

@ -20,7 +20,7 @@ module TasklistHelper
if log.id
send(path, log)
else
"/#{log.lettings? ? "lettings" : "sales"}-logs/new/#{next_question_page(subsection, log, current_user)}"
"/#{log.lettings? ? 'lettings' : 'sales'}-logs/new/#{next_question_page(subsection, log, current_user)}"
end
end

Loading…
Cancel
Save