-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/one_login' into use-one-login-fo…
…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
Showing
25 changed files
with
307 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
app/views/publishers/vacancies/base/_publish_date.html.slim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.