diff --git a/app/controllers/case_logs_controller.rb b/app/controllers/case_logs_controller.rb index f9b25bf8d..42d80c6ca 100644 --- a/app/controllers/case_logs_controller.rb +++ b/app/controllers/case_logs_controller.rb @@ -57,8 +57,7 @@ class CaseLogsController < ApplicationController def submit_form form = FormHandler.instance.get_form("2021_2022") @case_log = CaseLog.find(params[:id]) - @case_log.page_id = params[:case_log][:page] - page = form.get_page(@case_log.page_id) + page = form.get_page(params[:case_log][:page]) responses_for_page = responses_for_page(page) if @case_log.update(responses_for_page) && @case_log.has_no_unresolved_soft_errors? redirect_path = form.next_page_redirect_path(page, @case_log) diff --git a/app/models/case_log.rb b/app/models/case_log.rb index 94b5d4f54..acd65bb0c 100644 --- a/app/models/case_log.rb +++ b/app/models/case_log.rb @@ -1,6 +1,6 @@ class CaseLogValidator < ActiveModel::Validator - # Validations methods need to be called 'validate_' to run on model save - # or 'validate_' to run on submit as well + # Validations methods need to be called 'validate_' to run on model save + # or form page submission include HouseholdValidations include PropertyValidations include FinancialValidations @@ -8,16 +8,8 @@ class CaseLogValidator < ActiveModel::Validator include DateValidations def validate(record) - # If we've come from the form UI we only want to validate the specific fields - # that have just been submitted. If we're submitting a log via API or Bulk Upload - # we want to validate all data fields. - page_to_validate = record.page_id - if page_to_validate - public_send("validate_#{page_to_validate}", record) if respond_to?("validate_#{page_to_validate}") - else - validation_methods = public_methods.select { |method| method.starts_with?("validate_") } - validation_methods.each { |meth| public_send(meth, record) } - end + validation_methods = public_methods.select { |method| method.starts_with?("validate_") } + validation_methods.each { |meth| public_send(meth, record) } end private @@ -49,8 +41,6 @@ class CaseLog < ApplicationRecord scope :for_organisation, ->(org) { where(owning_organisation: org).or(where(managing_organisation: org)) } - attr_accessor :page_id - enum status: { "not_started" => 0, "in_progress" => 1, "completed" => 2 } enum ethnic: DbEnums.ethnic diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index cf69b955d..8f043f6ee 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -38,7 +38,14 @@ logotype: 'GOV.UK', service_name: 'Share Lettings and Sales for Social Housing in England Data with DLUHC', service_url: '/' - ) + ) do |component| + if current_user.nil? + component.navigation_item(text: 'Case logs', href: '/case_logs') + elsif + component.navigation_item(text: 'Your account', href: '/users/account') + component.navigation_item(text: 'Sign out', href: destroy_user_session_path, options: {:method => :delete}) + end + end %>