Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/one_login' into use-one-login-fo…
Browse files Browse the repository at this point in the history
…r-jobseekers

* origin/one_login:
  Bump Openssl version in docker image
  Raise exception if vacancy cannot be created
  All school roles content updates
  Relist job flow (#7146)
  • Loading branch information
scruti committed Oct 21, 2024
2 parents 0c3bf82 + 2feedf2 commit 38f6cae
Show file tree
Hide file tree
Showing 25 changed files with 307 additions and 83 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Alpine v3.19.
# TODO: Regularly check in the alpine ruby "3.3.5-alpine3.19" images for its latest upgraded packages so we can remove
# the hardcoded versions below when they have been updated in the alpine ruby image.
ARG PROD_PACKAGES="imagemagick libpng libjpeg libxml2 libxslt libpq tzdata shared-mime-info postgresql15 busybox=1.36.1-r19 openssl=3.1.7-r0"
ARG PROD_PACKAGES="imagemagick libpng libjpeg libxml2 libxslt libpq tzdata shared-mime-info postgresql15 busybox=1.36.1-r19 openssl=3.1.7-r1"

FROM ruby:3.3.5-alpine3.19 AS builder

Expand Down
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ group :test do
gem "rack_session_access"
gem "selenium-webdriver"
gem "shoulda-matchers"
gem "timecop"
gem "vcr"
gem "webmock"
end
Expand Down
2 changes: 0 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,6 @@ GEM
temple (0.10.3)
thor (1.3.2)
tilt (2.4.0)
timecop (0.9.10)
timeout (0.4.1)
trailblazer-option (0.1.2)
ttfunk (1.8.0)
Expand Down Expand Up @@ -849,7 +848,6 @@ DEPENDENCIES
spring
spring-commands-rspec
spring-watcher-listen
timecop
tzinfo-data
valid_email2
validate_url
Expand Down
18 changes: 14 additions & 4 deletions app/components/dashboard_component/dashboard_component.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,20 @@
p.govuk-body-xs.external-notice
= t("jobs.manage.external_notice")
- unless vacancy.external? || vacancy.draft?
- row.with_action(text: t("buttons.copy_listing"),
href: organisation_job_copy_path(vacancy.id),
visually_hidden_text: "for #{vacancy.job_title}",
html_attributes: { "data-method": "post" })
- if vacancy.expired?
- row.with_action(text: t("buttons.relist_vacancy"),
href: organisation_job_relist_path(vacancy.id),
visually_hidden_text: "for #{vacancy.job_title}",
html_attributes: { "data-method": "post" })
- row.with_action(text: t("buttons.copy_expired_listing"),
href: organisation_job_copy_path(vacancy.id),
visually_hidden_text: "for #{vacancy.job_title}",
html_attributes: { "data-method": "post" })
- else
- row.with_action(text: t("buttons.copy_listing"),
href: organisation_job_copy_path(vacancy.id),
visually_hidden_text: "for #{vacancy.job_title}",
html_attributes: { "data-method": "post" })

- unless @organisation.school_group?
.govuk-grid-column-one-quarter
Expand Down
36 changes: 14 additions & 22 deletions app/controllers/publishers/vacancies/extend_deadline_controller.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
class Publishers::Vacancies::ExtendDeadlineController < Publishers::Vacancies::BaseController
helper_method :form, :vacancy
helper_method :vacancy

def show
@form = Publishers::JobListing::ExtendDeadlineForm.new(
start_date_type: vacancy.start_date_type,
starts_on: vacancy.starts_on,
earliest_start_date: vacancy.earliest_start_date,
latest_start_date: vacancy.latest_start_date,
other_start_date_details: vacancy.other_start_date_details,
)
end

def update
if form.valid?
vacancy.update(form.attributes_to_save)
@form = Publishers::JobListing::ExtendDeadlineForm.new(form_params)
if @form.valid?
vacancy.update(@form.attributes_to_save)
update_google_index(vacancy)
redirect_to organisation_jobs_with_type_path(:published), success: t(".success", job_title: vacancy.job_title)
else
Expand All @@ -13,25 +24,6 @@ def update

private

def form
@form ||= Publishers::JobListing::ExtendDeadlineForm.new(form_attributes)
end

def form_attributes
case action_name
when "show"
{
start_date_type: vacancy.start_date_type,
starts_on: vacancy.starts_on,
earliest_start_date: vacancy.earliest_start_date,
latest_start_date: vacancy.latest_start_date,
other_start_date_details: vacancy.other_start_date_details,
}
when "update"
form_params
end
end

def form_params
params.require(:publishers_job_listing_extend_deadline_form)
.permit(:expires_at, :expiry_time, :start_date_type, :starts_on, :earliest_start_date, :latest_start_date, :other_start_date_details, :extension_reason, :other_extension_reason_details)
Expand Down
29 changes: 29 additions & 0 deletions app/controllers/publishers/vacancies/relist_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
class Publishers::Vacancies::RelistController < Publishers::Vacancies::BaseController
def create
vacancy.status = :draft
@vacancy = CopyVacancy.new(vacancy).call

@form = Publishers::JobListing::RelistForm.new

render :edit
end

def update
@form = Publishers::JobListing::RelistForm.new(relist_params)
if @form.valid?
vacancy.update(@form.attributes_to_save.merge(status: :published))
update_google_index(vacancy)
redirect_to organisation_job_summary_path(vacancy.id), success: t(".success", job_title: vacancy.job_title)
else
@vacancy = vacancy
render :edit
end
end

private

def relist_params
params.require(:publishers_job_listing_relist_form)
.permit(:expires_at, :expiry_time, :publish_on, :publish_on_day, :extension_reason, :other_extension_reason_details)
end
end
2 changes: 1 addition & 1 deletion app/controllers/publishers/vacancies_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def save_and_finish_later
end

def create
vacancy = Vacancy.create(publisher: current_publisher, publisher_organisation: current_organisation, organisations: [current_organisation])
vacancy = Vacancy.create!(publisher: current_publisher, publisher_organisation: current_organisation, organisations: [current_organisation])

if current_organisation.school?
vacancy.update(organisations: [current_organisation])
Expand Down
54 changes: 54 additions & 0 deletions app/form_models/publishers/job_listing/relist_form.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
class Publishers::JobListing::RelistForm < BaseForm
include ActiveRecord::AttributeAssignment
include DateAttributeAssignment

attr_reader :publish_on, :expires_at
attr_writer :publish_on_day

validates(:publish_on, date: { on_or_after: :today, on_or_before: :far_future }, unless: lambda do
publish_on_day.blank? || (publish_on.is_a?(Date) && (publish_on.today? || publish_on.tomorrow?))
end)
validates :publish_on_day, inclusion: { in: %w[today tomorrow another_day] }

attr_accessor :expiry_time, :extension_reason, :other_extension_reason_details

validates :expires_at, date: { on_or_after: :now, on_or_before: :far_future }
validates :expiry_time, inclusion: { in: Vacancy::EXPIRY_TIME_OPTIONS }

validates :extension_reason, inclusion: { in: Vacancy.extension_reasons.keys }

def initialize(params = {})
@params = params
super
end

def attributes_to_save
{
publish_on: publish_on,
expires_at: expires_at,
extension_reason: extension_reason,
other_extension_reason_details: other_extension_reason_details,
}
end

def expires_at=(value)
expires_on = date_from_multiparameter_hash(value)
@expires_at = datetime_from_date_and_time(expires_on, expiry_time)
end

def publish_on_day
return "today" if @publish_on_day == "today" || publish_on == Date.today
return "tomorrow" if @publish_on_day == "tomorrow" || publish_on == Date.tomorrow

"another_day" if @publish_on_day == "another_day" || publish_on.is_a?(Date)
end

def publish_on=(value)
@publish_on =
case @params[:publish_on_day]
when "today" then Date.today
when "tomorrow" then Date.tomorrow
else date_from_multiparameter_hash(value)
end
end
end
2 changes: 2 additions & 0 deletions app/helpers/vacancy_forms_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ def vacancy_review_form_heading_action_link(vacancy, action) # rubocop:disable M
govuk_link_to(t("publishers.vacancies.show.heading_component.action.close_early"), organisation_job_end_listing_path(vacancy.id), class: "govuk-!-margin-bottom-0")
when "extend_closing_date"
govuk_link_to(t("publishers.vacancies.show.heading_component.action.extend_closing_date"), organisation_job_extend_deadline_path(vacancy.id), class: "govuk-!-margin-bottom-0")
when "relist"
govuk_link_to(t("publishers.vacancies.show.heading_component.action.relist"), organisation_job_relist_path(vacancy.id), class: "govuk-!-margin-bottom-0", method: :post)
when "publish"
govuk_button_link_to(t("publishers.vacancies.show.heading_component.action.publish"), organisation_job_publish_path(vacancy.id), class: "govuk-!-margin-bottom-0")
when "preview"
Expand Down
8 changes: 4 additions & 4 deletions app/validators/date_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ class DateValidator < ActiveModel::EachValidator
}.freeze

DEFAULT_CHECK_VALUES = {
today: Date.current,
now: Time.current,
far_future: 2.years.from_now,
today: -> { Date.current },
now: -> { Time.current },
far_future: -> { 2.years.from_now },
}.freeze

def validate_each(record, attribute, value)
Expand All @@ -26,7 +26,7 @@ def validate_each(record, attribute, value)
DEFAULT_CHECK_VALUES.key?(restriction_option) || record.respond_to?(restriction_option)

if DEFAULT_CHECK_VALUES.key?(restriction_option)
value_to_compare = DEFAULT_CHECK_VALUES[restriction_option]
value_to_compare = DEFAULT_CHECK_VALUES[restriction_option].call
elsif record.respond_to?(restriction_option)
value_to_compare = record.send(restriction_option)
end
Expand Down
10 changes: 10 additions & 0 deletions app/views/publishers/vacancies/base/_publish_date.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
= f.govuk_radio_buttons_fieldset :publish_on_day, legend: { size: "m", tag: nil } do
= f.govuk_radio_button :publish_on_day, :today, link_errors: true,
label: { text: t("helpers.label.publishers_job_listing_important_dates_form.publish_on_day_options.today", date: Time.now.strftime("%-e %-B %Y")) }
= f.govuk_radio_button :publish_on_day, :tomorrow,
label: { text: t("helpers.label.publishers_job_listing_important_dates_form.publish_on_day_options.tomorrow", date: 1.day.from_now.strftime("%-e %-B %Y")) }
= f.govuk_radio_button :publish_on_day, :another_day,
label: { text: t("helpers.label.publishers_job_listing_important_dates_form.publish_on_day_options.another_day") } do
= f.govuk_date_field :publish_on,
legend: { tag: nil, text: t("helpers.label.publishers_job_listing_important_dates_form.publish_on_day_options.another_day") },
hint: -> { t("helpers.hint.date", date: 1.week.from_now.strftime("%-d %-m %Y")) }
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,7 @@
br
= f.govuk_date_field :publish_on, class: "govuk-!-display-none"
- else
= f.govuk_radio_buttons_fieldset :publish_on_day, legend: { size: "m", tag: nil } do
= f.govuk_radio_button :publish_on_day, :today, link_errors: true, label: { text: t("helpers.label.publishers_job_listing_important_dates_form.publish_on_day_options.today", date: Time.now.strftime("%-e %-B %Y")) }
= f.govuk_radio_button :publish_on_day, :tomorrow, label: { text: t("helpers.label.publishers_job_listing_important_dates_form.publish_on_day_options.tomorrow", date: 1.day.from_now.strftime("%-e %-B %Y")) }
= f.govuk_radio_button :publish_on_day, :another_day do
= f.govuk_date_field :publish_on,
legend: { tag: nil },
hint: -> { t("helpers.hint.date", date: 1.week.from_now.strftime("%-d %-m %Y")) }
= render "publish_date", f: f

= f.govuk_date_field :expires_at,
hint: -> { t("helpers.hint.date", date: 1.month.from_now.strftime("%-d %-m %Y")) },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
= vacancy.expired? ? t(".deadline.past") : t(".deadline.future")
strong =< format_time_to_datetime_at(vacancy.expires_at)

= form_for form, url: organisation_job_extend_deadline_path(vacancy.id), method: :patch do |f|
= form_for @form, url: organisation_job_extend_deadline_path(vacancy.id), method: :patch do |f|
= f.govuk_error_summary

= f.govuk_date_field :expires_at,
Expand Down
34 changes: 34 additions & 0 deletions app/views/publishers/vacancies/relist/edit.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
- content_for :page_title_prefix, t(".title", job_title: vacancy.job_title)

- content_for :breadcrumbs do
= govuk_back_link text: t("buttons.back"), href: organisation_job_path(@vacancy.id)

.govuk-grid-row
.govuk-grid-column-two-thirds
span.govuk-caption-l = t(".caption")
h1.govuk-heading-xl = t(".heading", job_title: @vacancy.job_title)

= form_for @form, url: organisation_job_relist_path(@vacancy.id), method: :patch do |f|
= f.govuk_error_summary

= render "publish_date", f: f

= f.govuk_date_field :expires_at,
hint: -> { t("helpers.hint.date", date: 1.month.from_now.strftime("%d %m %Y")) }

= f.govuk_collection_radio_buttons :expiry_time,
Vacancy::EXPIRY_TIME_OPTIONS,
->(option) { option },
->(option) { t("helpers.options.publishers_job_listing_extend_deadline_form.expiry_time.#{option}") }

= f.govuk_radio_buttons_fieldset :extension_reason, legend: { text: t(".reason_label") } do
= f.govuk_radio_button :extension_reason, :no_applications, link_errors: true, label: { text: t(".extension_reason.no_applications") }
= f.govuk_radio_button :extension_reason, :didnt_find_right_candidate, link_errors: true, label: { text: t(".extension_reason.didnt_find_right_candidate") }
= f.govuk_radio_button :extension_reason, :other_extension_reason, label: { text: t(".extension_reason.other_extension_reason") } do
= f.govuk_text_area :other_extension_reason_details,
label: { text: t(".extension_reason.other_details") },
rows: 5

= f.govuk_submit t("buttons.relist_vacancy"), class: "govuk-!-margin-bottom-5"

= govuk_link_to(t("buttons.cancel"), organisation_jobs_with_type_path, class: "govuk-link--no-visited-state govuk-!-font-size-19")
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ h1.govuk-heading-l class="govuk-!-display-inline"
= govuk_inset_text do
= vacancy_review_form_heading_inset_text(vacancy, "closed")
.govuk-button-group class="govuk-!-margin-top-4"
- %w[view copy extend_closing_date].each do |action|
= vacancy_review_form_heading_action_link(vacancy, action) unless vacancy.legacy? && action == "extend_closing_date"
- %w[view copy relist].each do |action|
= vacancy_review_form_heading_action_link(vacancy, action) unless vacancy.legacy? && action == "relist"
11 changes: 5 additions & 6 deletions config/locales/activerecord.yml
Original file line number Diff line number Diff line change
Expand Up @@ -446,12 +446,11 @@ en:
attributes:
<<: *important_dates_errors
<<: *start_date_errors
expires_at:
after: To extend the closing date enter a date that is after the current deadline
blank: Enter a closing date
invalid: Enter a date in the correct format
on_or_after: The closing date must be in the future
on_or_before: The closing date must be less than two years in the future
publishers/job_listing/relist_form:
attributes:
<<: *important_dates_errors
extension_reason:
inclusion: Select the reason why the vacancy is being relisted
publishers/login_keys/choose_organisation_form:
attributes:
organisation:
Expand Down
8 changes: 4 additions & 4 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ en:

nav:
create_a_job_alert: Create a job alert
find_job: Find a teaching job
find_job: Find a job
manage_jobs: Manage jobs
manage_settings: Manage settings
school_profile: School profile
Expand Down Expand Up @@ -145,7 +145,7 @@ en:

home:
index:
browse_all: Browse all teaching jobs in England
browse_all: Browse all teaching, leadership and school-based support jobs in England
description: Search for teaching, leadership and school-based support jobs in England.
jobseeker_section:
signed_in:
Expand Down Expand Up @@ -476,7 +476,7 @@ en:
intro: 'Candidate profiles are a new feature that allows schools to contact you about relevant jobs. With a profile you can:'
summary_list:
- share your qualifications with schools
- specify the types of teaching jobs you're looking for
- specify the types of jobs you're looking for
- apply for roles more quickly by pre-filling your information
link_to_profile: Create a profile to simplify your job search.

Expand Down Expand Up @@ -514,7 +514,7 @@ en:
vacancies:
index:
page_description: >-
Search for teaching jobs near you and other school jobs including headteacher and teaching assistant. Visit the official place to find teaching jobs.
Search for teaching, leadership and school-based support jobs near you. Visit the official place to find teaching and education support roles.
no_polygons: This search didn't use any polygons.
international_teacher_advice:
link: help you understand your next steps
Expand Down
7 changes: 7 additions & 0 deletions config/locales/forms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ en:
continue: Continue
continue_to_account: Continue to your account
continue_to_dsi: Continue to DfE Sign-in
copy_expired_listing: Copy
copy_listing: Copy job listing
copy_url: Copy URL
create_account: Create an account
Expand Down Expand Up @@ -65,6 +66,7 @@ en:
profile_update:
logo: Update organisation logo
photo: Update organisation photo
relist_vacancy: Relist
reject: Reject
reminder_continue: Continue to create a job
request_dsi_account: Request a DfE Sign-in account
Expand Down Expand Up @@ -1026,6 +1028,11 @@ en:
expiry_time: Closing time
publish_on: Another date
publish_on_day: Publish date
publishers_job_listing_relist_form:
expires_at: Closing date
expiry_time: Closing time
publish_on_day: Publish date
another_day: Another date
publishers_job_listing_include_additional_documents_form:
include_additional_documents: Do you want to upload any additional documents?
publishers_job_listing_start_date_form:
Expand Down
Loading

0 comments on commit 38f6cae

Please sign in to comment.