diff --git a/app/controllers/ad_banners_controller.rb b/app/controllers/ad_banners_controller.rb index 9a5f80e..1f89adc 100644 --- a/app/controllers/ad_banners_controller.rb +++ b/app/controllers/ad_banners_controller.rb @@ -1,7 +1,7 @@ class AdBannersController < ApplicationController def widget adbanner = Banner.find(OrbitHelper.widget_custom_value) - images = adbanner.ad_images.collect.with_index do |b,i| + images = adbanner.ad_images.can_display.collect.with_index do |b,i| image_link = OrbitHelper.is_mobile_view ? b.file.mobile.url : b.file.url klass = i == 0 ? "active" : "" caption = i == 0 ? '
' : "" diff --git a/app/controllers/admin/ad_banners_controller.rb b/app/controllers/admin/ad_banners_controller.rb index 89c3e35..5d39e51 100644 --- a/app/controllers/admin/ad_banners_controller.rb +++ b/app/controllers/admin/ad_banners_controller.rb @@ -1,8 +1,7 @@ class Admin::AdBannersController < OrbitAdminController - def index - @banners = Banner.order_by(sort).page(params[:page]).per(10) - @table_fields = ["ad_banner.banner_name","ad_banner.effect","ad_banner.transition_interval","ad_banner.transition_speed","ad_banner.size","preview"] + def index + @banners = Banner.all end def show diff --git a/app/controllers/admin/ad_images_controller.rb b/app/controllers/admin/ad_images_controller.rb index 5f6841a..4639b1a 100644 --- a/app/controllers/admin/ad_images_controller.rb +++ b/app/controllers/admin/ad_images_controller.rb @@ -1,5 +1,5 @@ class Admin::AdImagesController < Admin::AdBannersController - def initialize + def initialize super @app_title = "ad_banner" end @@ -12,8 +12,7 @@ class Admin::AdImagesController < Admin::AdBannersController def edit @ad_image = AdImage.find(params[:id]) if can_edit_or_delete?(@ad_image) - @ad_banners = Banner.all - @tags = @module_app.tags || [] + @ad_banner = @ad_image.banner else render_401 end @@ -22,7 +21,7 @@ class Admin::AdImagesController < Admin::AdBannersController def update @ad_image = AdImage.find(params[:id]) if @ad_image.update_attributes(ad_image_params) - redirect_to admin_ad_images_url + redirect_to params['referer_url'] else @ad_banners = Banner.all @tags = @module_app.tags || [] @@ -32,17 +31,16 @@ class Admin::AdImagesController < Admin::AdBannersController def new @ad_image = AdImage.new - @ad_banners = Banner.all + @ad_banner = Banner.find(params[:banner]) @tags = @module_app.tags || [] @ad_image.postdate = Date.today - @ad_image.deadline = Date.today + 30 end def create @ad_image = AdImage.new(ad_image_params) if @ad_image.save - redirect_to admin_ad_images_url + redirect_to params['referer_url'] else @ad_banners = Banner.all @tags = @module_app.tags || [] @@ -54,7 +52,7 @@ class Admin::AdImagesController < Admin::AdBannersController def destroy @ad_image = AdImage.find params[:id] if @ad_image.destroy - redirect_to admin_ad_images_url + redirect_to admin_ad_banners_url end end diff --git a/app/models/ad_image.rb b/app/models/ad_image.rb index 523c915..cb93691 100644 --- a/app/models/ad_image.rb +++ b/app/models/ad_image.rb @@ -20,7 +20,13 @@ class AdImage before_validation :add_http validates :file, presence: true validates :out_link, format: { with: URI::regexp(%w(http https)) }, allow_blank: true - validates :title, presence: true + # validates :title, presence: true + + scope :can_display, ->{self.and(AdImage.or({:postdate.lte=>Time.now},{:postdate=>nil}).selector,AdImage.or({:deadline.gte=>Time.now},{:deadline=>nil}).selector)} + + def expired? + self.deadline
- <%= banner.title %>
-
- <% if can_edit_or_delete?(banner) %>
-
+<%
+ height = 140
+%>
+
+ |
- <%= banner.ad_fx %> | -<%= banner.timeout %> | -<%= banner.speed %> | -<%= banner.size %> | -<%= banner.preview_link %> | -