Replace registration-period datepickers with date input
Nowadays all browsers have reasonable date input support...
This commit is contained in:
parent
f4d9561eaa
commit
07bfff8fa1
7 changed files with 39 additions and 68 deletions
|
|
@ -125,7 +125,7 @@ class Cfp < ApplicationRecord
|
|||
|
||||
def start_after_end_date
|
||||
errors
|
||||
.add(:start_date, "can't be after the end date") if start_date && end_date && start_date > end_date
|
||||
.add(:start_date, "can't be after the end date") if start_date > end_date
|
||||
end
|
||||
|
||||
def conference_id
|
||||
|
|
|
|||
|
|
@ -6,21 +6,32 @@ class RegistrationPeriod < ApplicationRecord
|
|||
has_paper_trail ignore: [:updated_at], meta: { conference_id: :conference_id }
|
||||
|
||||
validates :start_date, :end_date, presence: true
|
||||
validate :before_end_of_conference
|
||||
validate :start_before_end_of_conference
|
||||
validate :end_before_end_of_conference
|
||||
validate :start_date_before_end_date
|
||||
|
||||
private
|
||||
|
||||
def before_end_of_conference
|
||||
errors
|
||||
.add(:start_date, "can't be after the conference end date (#{conference.end_date})") if conference&.end_date && start_date && (start_date > conference.end_date)
|
||||
def start_before_end_of_conference
|
||||
return unless conference
|
||||
return unless start_date
|
||||
|
||||
errors
|
||||
.add(:end_date, "can't be after the conference end date (#{conference.end_date})") if conference&.end_date && end_date && (end_date > conference.end_date)
|
||||
.add(:start_date, "can't start after the conference end date (#{conference.end_date})") if start_date > conference.end_date
|
||||
end
|
||||
|
||||
def end_before_end_of_conference
|
||||
return unless conference
|
||||
return unless end_date
|
||||
|
||||
errors
|
||||
.add(:end_date, "can't end after the conference end date (#{conference.end_date})") if end_date > conference.end_date
|
||||
end
|
||||
|
||||
def start_date_before_end_date
|
||||
return unless start_date && end_date
|
||||
|
||||
errors
|
||||
.add(:start_date, "can't be after the end date") if start_date && end_date && start_date > end_date
|
||||
.add(:start_date, "can't be after the end date") if start_date > end_date
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue