Add validations to BroadcastMessage color and font
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
parent
e78c51f7cf
commit
d1e8495890
|
@ -20,6 +20,9 @@ class BroadcastMessage < ActiveRecord::Base
|
||||||
validates :starts_at, presence: true
|
validates :starts_at, presence: true
|
||||||
validates :ends_at, presence: true
|
validates :ends_at, presence: true
|
||||||
|
|
||||||
|
validates :color, format: { with: /\A\#[0-9A-Fa-f]{6}+\Z/ }, allow_blank: true
|
||||||
|
validates :font, format: { with: /\A\#[0-9A-Fa-f]{6}+\Z/ }, allow_blank: true
|
||||||
|
|
||||||
def self.current
|
def self.current
|
||||||
where("ends_at > :now AND starts_at < :now", now: Time.zone.now).last
|
where("ends_at > :now AND starts_at < :now", now: Time.zone.now).last
|
||||||
end
|
end
|
||||||
|
|
|
@ -21,11 +21,13 @@
|
||||||
.control-group.js-toggle-colors-container.hide
|
.control-group.js-toggle-colors-container.hide
|
||||||
= f.label :color, "Background Color"
|
= f.label :color, "Background Color"
|
||||||
.controls
|
.controls
|
||||||
= f.text_field :color
|
= f.text_field :color, placeholder: "#AA33EE"
|
||||||
|
.light Hex values as 3 double digit numbers, starting with a # sign.
|
||||||
.control-group.js-toggle-colors-container.hide
|
.control-group.js-toggle-colors-container.hide
|
||||||
= f.label :font, "Font Color"
|
= f.label :font, "Font Color"
|
||||||
.controls
|
.controls
|
||||||
= f.text_field :font
|
= f.text_field :font, placeholder: "#224466"
|
||||||
|
.light Hex values as 3 double digit numbers, starting with a # sign.
|
||||||
.control-group
|
.control-group
|
||||||
= f.label :starts_at
|
= f.label :starts_at
|
||||||
.controls.datetime-controls
|
.controls.datetime-controls
|
||||||
|
|
Loading…
Reference in New Issue