Commit d1e8495890ed28d221595e3a60c2df8567b277c1
1 parent
e78c51f7
Exists in
spb-stable
and in
3 other branches
Add validations to BroadcastMessage color and font
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Showing
2 changed files
with
7 additions
and
2 deletions
Show diff stats
app/models/broadcast_message.rb
... | ... | @@ -20,6 +20,9 @@ class BroadcastMessage < ActiveRecord::Base |
20 | 20 | validates :starts_at, presence: true |
21 | 21 | validates :ends_at, presence: true |
22 | 22 | |
23 | + validates :color, format: { with: /\A\#[0-9A-Fa-f]{6}+\Z/ }, allow_blank: true | |
24 | + validates :font, format: { with: /\A\#[0-9A-Fa-f]{6}+\Z/ }, allow_blank: true | |
25 | + | |
23 | 26 | def self.current |
24 | 27 | where("ends_at > :now AND starts_at < :now", now: Time.zone.now).last |
25 | 28 | end | ... | ... |
app/views/admin/broadcast_messages/index.html.haml
... | ... | @@ -21,11 +21,13 @@ |
21 | 21 | .control-group.js-toggle-colors-container.hide |
22 | 22 | = f.label :color, "Background Color" |
23 | 23 | .controls |
24 | - = f.text_field :color | |
24 | + = f.text_field :color, placeholder: "#AA33EE" | |
25 | + .light Hex values as 3 double digit numbers, starting with a # sign. | |
25 | 26 | .control-group.js-toggle-colors-container.hide |
26 | 27 | = f.label :font, "Font Color" |
27 | 28 | .controls |
28 | - = f.text_field :font | |
29 | + = f.text_field :font, placeholder: "#224466" | |
30 | + .light Hex values as 3 double digit numbers, starting with a # sign. | |
29 | 31 | .control-group |
30 | 32 | = f.label :starts_at |
31 | 33 | .controls.datetime-controls | ... | ... |