diff options
-rw-r--r-- | app/models/refinery/banners/banner.rb | 5 | ||||
-rw-r--r-- | app/views/refinery/banners/admin/banners/_form.html.erb | 7 | ||||
-rw-r--r-- | db/migrate/4_add_locale_to_banners.rb | 5 |
3 files changed, 16 insertions, 1 deletions
diff --git a/app/models/refinery/banners/banner.rb b/app/models/refinery/banners/banner.rb index 16aa8fd..1a43fa7 100644 --- a/app/models/refinery/banners/banner.rb +++ b/app/models/refinery/banners/banner.rb @@ -7,7 +7,7 @@ module Refinery acts_as_indexed :fields => [:name, :url, :title, :description] - attr_accessible :name, :title, :description, :image_id, :url, :is_active, :start_date, :expiry_date, :position, :page_ids + attr_accessible :name, :title, :description, :image_id, :url, :is_active, :start_date, :expiry_date, :position, :page_ids, :locale validates :name, :presence => true validates_presence_of :start_date @@ -25,6 +25,9 @@ module Refinery scope :published, lambda { not_expired.active.where("start_date <= ?", Time.now).order(:position) } + scope :publish_in_current_locale, lambda{ + not_expired.active.where("start_date <= ?", Time.now).where("locale = ? or locale = ''", ::I18n.locale) + } end end diff --git a/app/views/refinery/banners/admin/banners/_form.html.erb b/app/views/refinery/banners/admin/banners/_form.html.erb index 5230cb1..356719e 100644 --- a/app/views/refinery/banners/admin/banners/_form.html.erb +++ b/app/views/refinery/banners/admin/banners/_form.html.erb @@ -41,6 +41,13 @@ </div> + <% if Refinery::I18n.frontend_locales %> + <div class='field'> + <%= f.label :locale -%> + <%= f.select :locale, Refinery::I18n.frontend_locales, include_blank: true -%> + </div> + <% end %> + <div class='field'> <%= f.label :is_active -%> <%= f.check_box :is_active, :checked => @banner[:is_active] -%> diff --git a/db/migrate/4_add_locale_to_banners.rb b/db/migrate/4_add_locale_to_banners.rb new file mode 100644 index 0000000..11d553c --- /dev/null +++ b/db/migrate/4_add_locale_to_banners.rb @@ -0,0 +1,5 @@ +class AddLocaleToBanners < ActiveRecord::Migration + def change + add_column :refinery_banners, :locale, :string + end +end
\ No newline at end of file |