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:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
4
app/models/web_section.rb
Normal file
4
app/models/web_section.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
class WebSection < ActiveRecord::Base
|
||||
has_many :sections
|
||||
has_many :banners, through: :sections
|
||||
end
|
||||
Reference in New Issue
Block a user