Apply banner style to the new banners

Banner sections can be saved (one banner can appear in several sections)
If the hex color is changed in the textfield, the color of the color picker changes.
This commit is contained in:
iagirre
2018-01-15 11:25:14 +01:00
committed by Angel Perez
parent 6d6da8affc
commit 3690cae458
12 changed files with 56 additions and 30 deletions

View File

@@ -7,15 +7,13 @@ class Banner < ActiveRecord::Base
length: { minimum: 2 }
validates :description, presence: true
validates :target_url, presence: true
validates :style, presence: true
validates :image, presence: true
validates :post_started_at, presence: true
validates :post_ended_at, presence: true
has_many :sections
has_many :web_sections, through: :sections
scope :with_active, -> { where("post_started_at <= ?", Time.current).where("post_ended_at >= ?", Time.current) }
scope :with_inactive, -> { where("post_started_at > ? or post_ended_at < ?", Time.current, Time.current) }
end

View File

@@ -1,5 +1,4 @@
class Banner::Section < ActiveRecord::Base
enum sections: { homepage: 0, debates: 1, proposals: 2, budgets: 3, more_info: 4 }
belongs_to :banner
belongs_to :web_section
end

View File

@@ -0,0 +1,4 @@
class WebSection < ActiveRecord::Base
has_many :sections
has_many :banners, through: :sections
end