Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Faith school candidate #7335

Open
wants to merge 5 commits into
base: faith-schools-flow
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ class JobApplicationReviewComponent::CatholicReligiousInformationSection < JobAp
def initialize(job_application, allow_edit:, name:)
# only include the details form if we follow a religion
forms = if job_application.following_religion
%w[FollowingReligionForm CatholicReligionDetailsForm]
%w[CatholicFollowingReligionForm CatholicReligionDetailsForm]
else
%w[FollowingReligionForm]
%w[CatholicFollowingReligionForm]
end
super(job_application, forms: forms, name: name, allow_edit: allow_edit)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ class JobApplicationReviewComponent::NonCatholicReligiousInformationSection < Jo
def initialize(job_application, allow_edit:, name:)
# only include the details form if we follow a religion
forms = if job_application.following_religion
%w[SchoolEthosForm FollowingReligionForm NonCatholicReligionDetailsForm]
%w[SchoolEthosForm NonCatholicFollowingReligionForm NonCatholicReligionDetailsForm]
else
%w[SchoolEthosForm FollowingReligionForm]
%w[SchoolEthosForm NonCatholicFollowingReligionForm]
end
super(job_application, forms: forms, name: name, allow_edit: allow_edit)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,7 @@ def form
end

def form_class
if step.in? %i[catholic_following_religion non_catholic_following_religion]
Jobseekers::JobApplication::FollowingReligionForm
else
"jobseekers/job_application/#{step}_form".camelize.constantize
end
"jobseekers/job_application/#{step}_form".camelize.constantize
end

def form_attributes
Expand Down
6 changes: 1 addition & 5 deletions app/controllers/jobseekers/job_applications_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,7 @@ def all_steps_valid?
end

def step_valid?(step)
form_class = if step.in? %i[catholic_following_religion non_catholic_following_religion]
Jobseekers::JobApplication::FollowingReligionForm
else
"jobseekers/job_application/#{step}_form".camelize.constantize
end
form_class = "jobseekers/job_application/#{step}_form".camelize.constantize

attributes = form_class.storable_fields.index_with do |field|
case field
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# frozen_string_literal: true

class Jobseekers::JobApplication::CatholicFollowingReligionForm < Jobseekers::JobApplication::FollowingReligionForm
end
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ def self.fields
end
attribute :following_religion, :boolean

validates :following_religion, inclusion: { in: [true, false] }
validates :following_religion, inclusion: { in: [true, false], allow_nil: false }
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# frozen_string_literal: true

class Jobseekers::JobApplication::NonCatholicFollowingReligionForm < Jobseekers::JobApplication::FollowingReligionForm
end
6 changes: 3 additions & 3 deletions app/helpers/job_applications_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def religious_job_application_sample(vacancy)
religious_reference_type: "referee",
religious_referee_name: Faker::Name.name,
religious_referee_address: Faker::Address.full_address,
ethos_and_aims: Faker::Lorem.paragraph(sentence_count: 2),
ethos_and_aims: "",
religious_referee_role: "Priest",
religious_referee_email: Faker::Internet.email,
religious_referee_phone: Faker::PhoneNumber.phone_number,
Expand Down Expand Up @@ -197,8 +197,8 @@ def job_application_attributes # rubocop: disable Metrics/MethodLength, Metrics/
qualified_teacher_status: "yes",
statutory_induction_complete: "yes",
right_to_work_in_uk: "yes",
safeguarding_issue: "yes",
safeguarding_issue_details: Faker::Lorem.paragraph(sentence_count: 1),
safeguarding_issue: "no",
safeguarding_issue_details: "",
qualified_teacher_status_year: "2021",
email_address: "[email protected]",
support_needed: "yes",
Expand Down
65 changes: 27 additions & 38 deletions app/helpers/status_tag_helper.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,32 @@
module StatusTagHelper
STATUS_COLOURS = {
optional: "grey",
not_started: "grey",
action_required: "red",
complete: "green",
in_progress: "yellow",
imported: "blue",
}.freeze
# rubocop:disable Lint/DuplicateBranch
def review_section_tag(resource, steps, form_classes)
if resource.is_a?(JobApplication) && steps.all? { |step| job_application_step_imported?(resource, step) }
imported
elsif form_classes.all?(&:optional?)
optional
elsif resource.is_a?(JobApplication) && steps.all? { |step| job_application_step_in_progress?(resource, step) }
in_progress
elsif steps.none? { |step| step_completed?(resource, step) }
not_started
elsif step_forms_contain_errors?(resource, form_classes)
action_required
else
complete
end
end
status = if resource.is_a?(JobApplication) && steps.all? { |step| job_application_step_imported?(resource, step) }
:imported
elsif form_classes.all?(&:optional?)
:optional
elsif resource.is_a?(JobApplication) && steps.all? { |step| job_application_step_in_progress?(resource, step) }
:in_progress
elsif steps.none? { |step| step_completed?(resource, step) }
:not_started
elsif step_forms_contain_errors?(resource, form_classes)
:action_required
elsif steps.all? { |step| step_completed?(resource, step) }
:complete
else
:in_progress
end
govuk_tag(text: t("shared.status_tags.#{status}"), colour: STATUS_COLOURS.fetch(status))
end
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice refactor.

# rubocop:enable Lint/DuplicateBranch

private

Expand All @@ -26,28 +39,4 @@ def step_forms_contain_errors?(resource, form_classes)
form_class.fields.any? { |field| resource.errors.include?(field) }
end
end

def optional
govuk_tag(text: t("shared.status_tags.optional"), colour: "grey")
end

def not_started
govuk_tag(text: t("shared.status_tags.not_started"), colour: "grey")
end

def action_required
govuk_tag(text: t("shared.status_tags.action_required"), colour: "red")
end

def complete
govuk_tag(text: t("shared.status_tags.complete"), colour: "green")
end

def in_progress
govuk_tag(text: t("shared.status_tags.in_progress"), colour: "yellow")
end

def imported
govuk_tag(text: t("shared.status_tags.imported"), colour: "blue")
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ def attributes_to_copy
professional_status
ask_for_support
personal_statement
following_religion
catholic_following_religion
non_catholic_following_religion
catholic_religion_details
school_ethos
non_catholic_religion_details]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
= f.govuk_error_summary

= f.govuk_radio_buttons_fieldset :following_religion do
= f.govuk_radio_button :following_religion, true, link_errors: true, label: { text: t("helpers.label.jobseekers_job_application_following_religion_form.following_religion_options.yes") }
= f.govuk_radio_button :following_religion, false, label: { text: t("helpers.label.jobseekers_job_application_following_religion_form.following_religion_options.no") }
= f.govuk_radio_button :following_religion, true, link_errors: true
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is boolean and the "false" bellow is a string. The "true" in the non-catholic view is also a string.

Is this ok?

= f.govuk_radio_button :following_religion, "false"

= f.govuk_submit job_application_build_submit_button_text do
= govuk_link_to t("buttons.cancel_and_return_to_account"), jobseekers_job_applications_path, class: "govuk-link--no-visited-state"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
= f.govuk_error_summary

= f.govuk_radio_buttons_fieldset :following_religion do
= f.govuk_radio_button :following_religion, true, link_errors: true, label: { text: t("helpers.label.jobseekers_job_application_following_religion_form.following_religion_options.yes") }
= f.govuk_radio_button :following_religion, false, label: { text: t("helpers.label.jobseekers_job_application_following_religion_form.following_religion_options.no") }
= f.govuk_radio_button :following_religion, "true", link_errors: true
= f.govuk_radio_button :following_religion, "false"

= f.govuk_submit job_application_build_submit_button_text do
= govuk_link_to t("buttons.cancel_and_return_to_account"), jobseekers_job_applications_path, class: "govuk-link--no-visited-state"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
= govuk_summary_list do |summary_list|
- if job_application.following_religion.in? [true, false]
- summary_list.with_row do |row|
- row.with_key text: t("helpers.legend.jobseekers_job_application_following_religion_form.following_religion")
- row.with_value text: job_application.following_religion ? t("helpers.label.jobseekers_job_application_following_religion_form.following_religion_options.yes") : t("helpers.label.jobseekers_job_application_following_religion_form.following_religion_options.no")
- row.with_key text: t("helpers.legend.jobseekers_job_application_catholic_following_religion_form.following_religion")
- row.with_value text: t("helpers.label.jobseekers_job_application_catholic_following_religion_form.following_religion_options.#{job_application.following_religion}")

- if job_application.following_religion
- summary_list.with_row do |row|
Expand All @@ -18,7 +18,10 @@

- summary_list.with_row do |row|
- row.with_key text: t("helpers.legend.jobseekers_job_application_catholic_religion_details_form.religious_reference_type")
- row.with_value text: t("helpers.label.jobseekers_job_application_catholic_religion_details_form.religious_reference_type_options.#{job_application.religious_reference_type}")
- if job_application.religious_reference_type.present?
- row.with_value text: t("helpers.label.jobseekers_job_application_catholic_religion_details_form.religious_reference_type_options.#{job_application.religious_reference_type}")
- else
- row.with_value text: ""

- case job_application.religious_reference_type
- when "referee"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

- if job_application.following_religion.in? [true, false]
- summary_list.with_row do |row|
- row.with_key text: t("helpers.legend.jobseekers_job_application_following_religion_form.following_religion")
- row.with_value text: job_application.following_religion ? t("helpers.label.jobseekers_job_application_following_religion_form.following_religion_options.yes") : t("helpers.label.jobseekers_job_application_following_religion_form.following_religion_options.no")
- row.with_key text: t("helpers.legend.jobseekers_job_application_non_catholic_following_religion_form.following_religion")
- row.with_value text: t("helpers.label.jobseekers_job_application_non_catholic_following_religion_form.following_religion_options.#{job_application.following_religion}")

- if job_application.following_religion
- summary_list.with_row do |row|
Expand All @@ -22,7 +22,7 @@

- summary_list.with_row do |row|
- row.with_key text: t("helpers.legend.jobseekers_job_application_catholic_religion_details_form.religious_reference_type")
- row.with_value text: job_application.religious_reference_type == "referee" ? t("helpers.label.jobseekers_job_application_following_religion_form.following_religion_options.yes") : t("helpers.label.jobseekers_job_application_following_religion_form.following_religion_options.no")
- row.with_value text: t("helpers.label.jobseekers_job_application_non_catholic_following_religion_form.following_religion_options.#{job_application.religious_reference_type == 'referee'}")

- if job_application.religious_reference_type == "referee"
- summary_list.with_row do |row|
Expand Down
16 changes: 12 additions & 4 deletions config/locales/activerecord.yml
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,11 @@ en:
attributes:
personal_statement:
blank: Enter your personal statement
jobseekers/job_application/following_religion_form:
jobseekers/job_application/catholic_following_religion_form:
attributes:
following_religion:
inclusion: Select yes if you follow a specific religion or faith
jobseekers/job_application/non_catholic_following_religion_form:
attributes:
following_religion:
inclusion: Select yes if you follow a specific religion or faith
Expand All @@ -570,7 +574,7 @@ en:
blank: Enter your referee role
religious_referee_email:
blank: Enter your referee email address
email: Enter a valid email address
invalid: Enter a valid email address
religious_reference_type:
inclusion: Select if you can provide a religious referee
baptism_address:
Expand All @@ -591,7 +595,7 @@ en:
blank: Enter your referee role
religious_referee_email:
blank: Enter your referee email address
email: Enter a valid email address
invalid: Enter a valid email address
religious_reference_type:
inclusion: Select yes if you can provide a religious referee
jobseekers/job_application/school_ethos_form:
Expand Down Expand Up @@ -644,7 +648,11 @@ en:
incomplete: Complete your qualifications
references:
incomplete: Complete your references
following_religion:
school_ethos:
incomplete: Complete the question about how you meet the schools ethos and aims
catholic_following_religion:
incomplete: Complete your religious information
non_catholic_following_religion:
incomplete: Complete your religious information
catholic_religion_details:
incomplete: Complete your religious information
Expand Down
51 changes: 0 additions & 51 deletions config/locales/forms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,18 +182,6 @@ en:
benefit letter, payslip or P60. It's made up of 2 letters, 6 numbers and a final letter.
phone_number: Enter a phone number you are happy to be contacted on. For example, 01632 960 001, 07700 900 982 or +44 0808 157 0192.
previous_names: For example maiden name or name at birth, if different from the name you have now.
jobseekers_job_application_catholic_religion_details_form:
baptism_date: For example 27 3 2007
faith: For example, Christian.
religious_reference_type_html: >-
<p class="govuk-hint">If you are a practising Catholic, you should nominate your Parish Priest where you regularly worship as your referee.</p>
<p class="govuk-hint">If you are not a practising Catholic, you can provide a copy of your baptism certificate, or the date and address of your baptism.</p>
<p class="govuk-hint">Make sure your referee has consented to providing a reference.</p>
jobseekers_job_application_non_catholic_religion_details_form:
faith: For example, Christian.
place_of_worship: For example, Westminster Abbey, Dean's Yard, London.
jobseekers_job_application_school_ethos_form:
ethos_and_aims: For example, through running after school clubs or supporting the school's local community.
jobseekers_qualifications_degree_form:
institution: For example, a university or college
qualifications_section_completed: Ensure you've added all the education and qualifications you've done.
Expand Down Expand Up @@ -544,38 +532,6 @@ en:
training_and_cpds_section_completed_options:
false: No, I'll come back to it later
true: Yes, I've completed this section
jobseekers_job_application_following_religion_form:
following_religion_options:
"yes": "Yes"
"no": "No"
jobseekers_job_application_catholic_religion_details_form:
religious_reference_type_options:
referee: "Yes"
baptism_certificate: No, but I can provide a baptism certificate
baptism_date: No, but I can provide the date and address of my baptism
no_referee: "No"
religious_referee_name: Religious referee name
religious_referee_address: Religious referee address
religious_referee_role: Religious referee role
religious_referee_email: Religious referee email
religious_referee_phone: Religious referee phone number (optional)
baptism_certificate: Upload a file
baptism_address: Address of baptism location
faith: What is your religious denomination or faith?
place_of_worship: Address of place of worship (optional)
jobseekers_job_application_non_catholic_religion_details_form:
religious_reference_type_options:
"referee": "Yes"
"no_referee": "No"
religious_referee_name: Religious referee name
religious_referee_address: Religious referee address
religious_referee_role: Religious referee role
religious_referee_email: Religious referee email
religious_referee_phone: Religious referee phone number (optional)
faith: What is your religious denomination or faith?
place_of_worship: Address of place of worship (optional)
jobseekers_job_application_school_ethos_form:
ethos_and_aims: How will you support the school's ethos and aims?
jobseekers_job_application_review_form:
update_profile_options:
qualifications: Update qualifications on profile
Expand Down Expand Up @@ -966,13 +922,6 @@ en:
gender: How would you describe your gender?
orientation: How would you describe your sexual orientation?
religion: What is your religion or belief?
jobseekers_job_application_following_religion_form:
following_religion: Are you currently following a religion or faith?
jobseekers_job_application_catholic_religion_details_form:
religious_reference_type: Can you provide a religious referee?
baptism_date: What was the date of your baptism?
jobseekers_job_application_non_catholic_religion_details_form:
religious_reference_type: Can you provide a religious referee?
jobseekers_break_form:
ended_on: End of gap
started_on: Start of gap
Expand Down
Loading
Loading