Browse Source

sales logs are now working

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

27
app/controllers/form_controller.rb

@ -131,28 +131,31 @@ 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")
SalesLog.new
else
LettingsLog.new
end
current_user.sales_logs.find_by(id: params[:sales_log_id])
elsif new_log_request?
if request.path.include?("sales-logs")
SalesLog.new
else
current_user.lettings_logs.find_by(id: params[:lettings_log_id])
LettingsLog.new
end
else
current_user.lettings_logs.find_by(id: params[:lettings_log_id])
end
end

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

4
app/helpers/tasklist_helper.rb

@ -16,11 +16,11 @@ module TasklistHelper
"#{log.class.name.underscore}_#{subsection.id}_check_answers_path"
else
"#{log.class.name.underscore}_#{next_question_page(subsection, log, current_user)}_path"
end
end
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