adbanner-test/app/controllers/admin/ad_images_controller.rb

63 lines
1.5 KiB
Ruby
Raw Normal View History

2014-05-05 04:50:33 +00:00
class Admin::AdImagesController < Admin::AdBannersController
2014-08-14 11:54:21 +00:00
def initialize
super
@app_title = "ad_banner"
end
2014-04-11 07:47:33 +00:00
def index
2014-07-16 07:20:25 +00:00
@ad_images = AdImage.order_by(sort).page(params[:page]).per(10)
@table_fields = ["preview","ad_banner.banner","title","start_date","end_date", "link"]
2014-04-11 07:47:33 +00:00
end
def edit
@ad_image = AdImage.find(params[:id])
@item = [[t('image'),"1"],['Youtube',"2"],[t('video'),"3"]]
2021-04-10 09:12:40 +00:00
@item_choose = @ad_image.exchange_item
2016-01-05 11:57:19 +00:00
if can_edit_or_delete?(@ad_image.banner)
2014-08-14 11:54:21 +00:00
@ad_banner = @ad_image.banner
2014-07-31 09:42:11 +00:00
else
render_401
end
2014-04-11 07:47:33 +00:00
end
def update
2016-01-05 11:57:19 +00:00
ad_image = AdImage.find(params[:id])
ad_image.update_attributes(ad_image_params)
redirect_to params[:referer_url]
end
def new
@ad_image = AdImage.new
2016-01-05 11:57:19 +00:00
@ad_banner = Banner.find(params[:banner_id])
@item = [[t('image'),"1"],['Youtube',"2"],[t('video'),"3"]]
2016-01-05 11:57:19 +00:00
if can_edit_or_delete?(@ad_banner)
@tags = @module_app.tags || []
@ad_image.postdate = Date.today
else
render_401
end
end
2014-04-11 07:47:33 +00:00
def create
@ad_image = AdImage.new(ad_image_params)
2016-01-05 11:57:19 +00:00
@ad_image.save
redirect_to params[:referer_url]
end
def destroy
2016-01-05 11:57:19 +00:00
ad_image = AdImage.find params[:id]
banner = ad_image.banner
ad_image.destroy
redirect_to admin_ad_banner_path(banner.id, :page => params[:page])
2014-04-11 07:47:33 +00:00
end
private
def ad_image_params
params.require(:ad_image).permit!
end
def setup_vars
@module_app = ModuleApp.where(:key => "ad_banner").first
2014-04-11 07:47:33 +00:00
end
end