aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDries Steenhouwer <steenhouwer.dries@gmail.com>2015-02-05 16:08:04 +0100
committerDries Steenhouwer <steenhouwer.dries@gmail.com>2015-02-05 16:08:04 +0100
commit1277f7634650f9525d8ffea679c47a15833cbc87 (patch)
tree84fe8286a35e3e8cf47fe4685d5ef01577634047
parentf94b05546856fbb0d8051226b47b9812f108a935 (diff)
downloadrefinerycms-pc_banners-1277f7634650f9525d8ffea679c47a15833cbc87.tar.gz
refinerycms-pc_banners-1277f7634650f9525d8ffea679c47a15833cbc87.tar.bz2
refinerycms-pc_banners-1277f7634650f9525d8ffea679c47a15833cbc87.zip
make homepage ready
-rw-r--r--app/controllers/refinery/banners/admin/banners_controller.rb5
-rw-r--r--app/models/refinery/banners/banner.rb6
-rw-r--r--app/views/refinery/banners/admin/banners/_form.html.erb6
-rw-r--r--db/migrate/1_create_banners_banners.rb2
-rw-r--r--lib/page_extensions.rb32
-rw-r--r--refinerycms-pc_banners.gemspec4
6 files changed, 35 insertions, 20 deletions
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 @@
</div>
+ <div class='field'>
+ <%= f.label :category -%>
+ <%= f.text_field :category -%>
+
+ </div>
+
<% if Refinery::I18n.frontend_locales %>
<div class='field'>
<%= f.label :locale -%>
diff --git a/db/migrate/1_create_banners_banners.rb b/db/migrate/1_create_banners_banners.rb
index f9e350a..f815020 100644
--- a/db/migrate/1_create_banners_banners.rb
+++ b/db/migrate/1_create_banners_banners.rb
@@ -11,6 +11,8 @@ class CreateBannersBanners < ActiveRecord::Migration
t.date :start_date
t.date :expiry_date
t.integer :position
+ t.string :category
+ t.text :body
t.timestamps
end
diff --git a/lib/page_extensions.rb b/lib/page_extensions.rb
index d28c10c..973c177 100644
--- a/lib/page_extensions.rb
+++ b/lib/page_extensions.rb
@@ -1,17 +1,17 @@
-# module Refinery
-# module Banners
-# module Extensions
-# module Page
-# module ClassMethods
-# def add_banners_relationship
-# has_and_belongs_to_many :banners, :class_name => '::Refinery::Banners::Banner', :join_table => 'refinery_banners_pages'
-# end
-# end
+module Refinery
+ module Banners
+ module Extensions
+ module Page
+ module ClassMethods
+ def add_banners_relationship
+ has_and_belongs_to_many :banners, :class_name => '::Refinery::Banners::Banner', :join_table => 'refinery_banners_pages'
+ end
+ end
-# def self.included(base)
-# base.extend(ClassMethods).add_banners_relationship
-# end
-# end
-# end
-# end
-# end \ No newline at end of file
+ def self.included(base)
+ base.extend(ClassMethods).add_banners_relationship
+ end
+ end
+ end
+ end
+end \ No newline at end of file
diff --git a/refinerycms-pc_banners.gemspec b/refinerycms-pc_banners.gemspec
index d7d0a66..ecc7881 100644
--- a/refinerycms-pc_banners.gemspec
+++ b/refinerycms-pc_banners.gemspec
@@ -14,8 +14,8 @@ Gem::Specification.new do |s|
s.homepage = 'https://github.com/julesce/refinerycms-pods'
# Runtime dependencies
- s.add_dependency 'refinerycms-pages', '~> 3.0.0.dev'
+ s.add_dependency 'refinerycms-pages', '~> 3.0.0'
# Development dependencies (usually used for testing)
- s.add_development_dependency 'refinerycms-testing', '~> 3.0.0.dev'
+ s.add_development_dependency 'refinerycms-testing', '~> 3.0.0'
end