2012-11-20 07:47:07 +00:00
|
|
|
class Admin::AdImagesController < Admin::AdBannersController
|
2012-11-20 06:24:49 +00:00
|
|
|
|
2012-11-20 07:47:07 +00:00
|
|
|
# before_filter :force_order_for_user
|
|
|
|
# before_filter :for_app_sub_manager
|
|
|
|
# before_filter :for_app_manager
|
|
|
|
|
|
|
|
def initialize
|
|
|
|
super
|
|
|
|
@app_title = "ad_banner"
|
|
|
|
end
|
2012-05-18 02:50:53 +00:00
|
|
|
|
2013-08-05 10:30:35 +00:00
|
|
|
def index
|
2013-08-09 01:24:26 +00:00
|
|
|
#@ad_banner = AdBanner.find params[:ad_banner_id]
|
|
|
|
#@ad_images = @ad_banner.ad_images.all.page(params[:page]).per(10)
|
|
|
|
@ad_images = AdImage.all.page(params[:page]).per(10)
|
2013-08-05 10:30:35 +00:00
|
|
|
end
|
|
|
|
|
2012-04-01 15:39:49 +00:00
|
|
|
def edit
|
2013-08-09 01:24:26 +00:00
|
|
|
#@ad_banner = AdBanner.find params[:ad_banner_id]
|
|
|
|
@ad_image = AdImage.find(params[:id])
|
2013-08-05 10:30:35 +00:00
|
|
|
@tags = get_tags
|
2012-04-01 15:39:49 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
2013-08-09 01:24:26 +00:00
|
|
|
@ad_image = AdImage.find(params[:id])
|
2012-04-01 15:39:49 +00:00
|
|
|
@ad_image.update_attributes(params[:ad_image])
|
2013-08-09 01:24:26 +00:00
|
|
|
redirect_to admin_ad_images_path
|
2012-04-01 15:39:49 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def new
|
2013-08-09 01:24:26 +00:00
|
|
|
#ad_banner = AdBanner.find params[:ad_banner_id]
|
|
|
|
#@ad_image =ad_banner.ad_images.build
|
|
|
|
@ad_image = AdImage.new
|
2012-04-23 10:20:12 +00:00
|
|
|
@ad_image.post_date = Date.today
|
|
|
|
@ad_image.unpost_date = Date.today + 30
|
2013-08-05 10:30:35 +00:00
|
|
|
@tags = get_tags
|
2012-04-01 15:39:49 +00:00
|
|
|
#render :action => 'new',:url=> {:ad_banner_id => params.has_key?(:ad_banner_id)? params[:ad_banner_id],nil}
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
2013-08-09 01:24:26 +00:00
|
|
|
# @ad_banner = AdBanner.find params[:ad_banner][:id]
|
|
|
|
@ad_image = AdImage.new params[:ad_image]
|
|
|
|
#@ad_image.to_save = true
|
|
|
|
#@ad_banner.ad_images << ad_image
|
2012-04-01 15:39:49 +00:00
|
|
|
|
2013-08-09 01:24:26 +00:00
|
|
|
if @ad_image.save
|
|
|
|
redirect_to admin_ad_images_path
|
2012-04-01 15:39:49 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
2013-08-09 01:24:26 +00:00
|
|
|
#@ad_banner = AdBanner.find params[:ad_banner_id]
|
|
|
|
@ad_image = AdImage.find params[:id]
|
2012-04-01 15:39:49 +00:00
|
|
|
if @ad_image.destroy
|
2012-09-12 11:12:50 +00:00
|
|
|
flash[:notice] = t('ad.success_destroy_ad_image')
|
2013-08-09 01:24:26 +00:00
|
|
|
redirect_to admin_ad_images_path
|
2012-04-01 15:39:49 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
end
|