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.

47 lines
1.3 KiB

3 years ago
class CaseLogsController < ApplicationController
def index
@submitted_case_logs = CaseLog.where(status: 1)
@in_progress_case_logs = CaseLog.where(status: 0)
end
3 years ago
def create
@case_log = CaseLog.create!
redirect_to @case_log
end
# We don't have a dedicated non-editable show view
3 years ago
def show
@case_log = CaseLog.find(params[:id])
render :edit
3 years ago
end
def edit
@case_log = CaseLog.find(params[:id])
end
FIRST_QUESTION_FOR_SUBSECTION = {
"Household characteristics" => "case_logs/household/tenant_code",
}.freeze
NEXT_QUESTION = {
"tenant_code" => "case_logs/household/tenant_age",
"tenant_age" => "case_logs/household/tenant_gender",
"tenant_gender" => "case_logs/household/tenant_ethnic_group",
"tenant_ethnic_group" => "case_logs/household/tenant_nationality",
}.freeze
def next_question
subsection = params[:subsection]
@case_log = CaseLog.find(params[:case_log_id])
result = if subsection
FIRST_QUESTION_FOR_SUBSECTION[subsection]
else
previous_question = params[:previous_question]
answer = params[previous_question]
@case_log.update(previous_question => answer)
NEXT_QUESTION[previous_question]
end
render result, locals: { case_log_id: @case_log.id }
end
3 years ago
end