From 1277f7634650f9525d8ffea679c47a15833cbc87 Mon Sep 17 00:00:00 2001 From: Dries Steenhouwer Date: Thu, 5 Feb 2015 16:08:04 +0100 Subject: make homepage ready --- app/controllers/refinery/banners/admin/banners_controller.rb | 5 +++++ app/models/refinery/banners/banner.rb | 6 ++++-- app/views/refinery/banners/admin/banners/_form.html.erb | 6 ++++++ 3 files changed, 15 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/controllers/refinery/banners/admin/banners_controller.rb b/app/controllers/refinery/banners/admin/banners_controller.rb index 1992bcf..759476a 100644 --- a/app/controllers/refinery/banners/admin/banners_controller.rb +++ b/app/controllers/refinery/banners/admin/banners_controller.rb @@ -6,6 +6,11 @@ module Refinery crudify :'refinery/banners/banner', :title_attribute => 'name', :xhr_paging => true + private + def banner_params + params.require(:banner).permit! + end + end end end diff --git a/app/models/refinery/banners/banner.rb b/app/models/refinery/banners/banner.rb index 08b4b38..bccf63c 100644 --- a/app/models/refinery/banners/banner.rb +++ b/app/models/refinery/banners/banner.rb @@ -13,7 +13,7 @@ module Refinery validates_presence_of :start_date validates_length_of :title, :in => 0..255, :allow_nil => true validates_length_of :description, :in => 0..255, :allow_nil => true - + belongs_to :image, :class_name => '::Refinery::Image' has_and_belongs_to_many :pages, :class_name => '::Refinery::Page', :join_table => 'refinery_banners_pages' @@ -21,7 +21,7 @@ module Refinery banners = Arel::Table.new(::Refinery::Banners::Banner.table_name) where(banners[:expiry_date].eq(nil).or(banners[:expiry_date].gt(Time.now))) } - scope :active, where(:is_active => true) + scope :active, lambda { where(:is_active => true) } scope :published, lambda { not_expired.active.where("start_date <= ?", Time.now).order(:position) } @@ -29,6 +29,8 @@ module Refinery not_expired.active.where("start_date <= ?", Time.now).where("locale = ? or locale = ''", ::I18n.locale).order(:position) } + scope :in_category, ->(cat) { where(:category => cat)} + end end end \ No newline at end of file diff --git a/app/views/refinery/banners/admin/banners/_form.html.erb b/app/views/refinery/banners/admin/banners/_form.html.erb index 356719e..c4fbd21 100644 --- a/app/views/refinery/banners/admin/banners/_form.html.erb +++ b/app/views/refinery/banners/admin/banners/_form.html.erb @@ -41,6 +41,12 @@ +
+ <%= f.label :category -%> + <%= f.text_field :category -%> + +
+ <% if Refinery::I18n.frontend_locales %>
<%= f.label :locale -%> -- cgit v1.2.3