Skip to content

Commit

Permalink
convert baptism_date to date field
Browse files Browse the repository at this point in the history
  • Loading branch information
starswan committed Jan 20, 2025
1 parent 720b466 commit 5a1777f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ def update

if redirect_to_review?
redirect_to jobseekers_job_application_review_path(job_application), success: t("messages.jobseekers.job_applications.saved")
elsif step_process.last_of_group?(step) || (step.in?(%i[catholic_following_religion non_catholic_following_religion]) && !job_application.following_religion)
elsif steps_complete?
redirect_to jobseekers_job_application_apply_path job_application
else
next_step = step_process.steps[step_process.steps.index(step) + 1]
redirect_to jobseekers_job_application_build_path(job_application, next_step)
redirect_to jobseekers_job_application_build_path(job_application, step_process.next_step(step))
end
else
render step
Expand All @@ -27,6 +26,10 @@ def update

private

def steps_complete?
step_process.last_of_group?(step) || (step.in?(%i[catholic_following_religion non_catholic_following_religion]) && !job_application.following_religion)
end

def back_path
@back_path ||= if redirect_to_review?
jobseekers_job_application_review_path(job_application)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class Jobseekers::JobApplication::CatholicReligionDetailsForm < Jobseekers::JobApplication::BaseForm
include ActiveRecord::AttributeAssignment
include DateAttributeAssignment
include ActiveModel::Attributes

FIELDS = %i[faith
place_of_worship
Expand All @@ -11,12 +11,13 @@ class Jobseekers::JobApplication::CatholicReligionDetailsForm < Jobseekers::JobA
religious_referee_email
religious_referee_phone
baptism_certificate
baptism_address
baptism_date].freeze
baptism_address].freeze

STORABLE_FIELDS = (FIELDS + [:baptism_date]).freeze

class << self
def storable_fields
FIELDS
STORABLE_FIELDS
end

def load_form(model)
Expand All @@ -26,6 +27,8 @@ def load_form(model)

attr_accessor(*FIELDS)

attribute :baptism_date, :date

validates :faith, presence: true
validates :religious_reference_type, inclusion: { in: JobApplication::RELIGIOUS_REFERENCE_TYPES.keys.map(&:to_s), nil: false }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ def steps
@step_groups.values.flatten
end

def next_step(step)
steps[steps.index(step) + 1]
end

def last_of_group?(step)
group = @step_groups.values.detect { |g| g.include?(step) }
step == group.last
Expand Down

0 comments on commit 5a1777f

Please sign in to comment.