2014-05-05 04:50:33 +00:00
|
|
|
class Admin::AdBannersController < OrbitAdminController
|
2014-08-15 03:22:02 +00:00
|
|
|
before_action ->(module_app = @app_title) { set_variables module_app }
|
2014-05-05 04:50:33 +00:00
|
|
|
|
2014-08-14 11:54:21 +00:00
|
|
|
def index
|
|
|
|
@banners = Banner.all
|
2015-02-24 09:40:15 +00:00
|
|
|
@categories = @module_app.categories.enabled.collect{|c|[c.title, c.id]}
|
2014-05-05 04:50:33 +00:00
|
|
|
end
|
2014-05-09 08:42:23 +00:00
|
|
|
|
2014-04-11 07:47:33 +00:00
|
|
|
def show
|
2014-05-09 08:42:23 +00:00
|
|
|
@ad_banners = Banner.all
|
2014-04-11 07:47:33 +00:00
|
|
|
@active = Banner.find(params[:id])
|
|
|
|
render :action => 'index'
|
|
|
|
end
|
2014-05-09 08:42:23 +00:00
|
|
|
|
2014-04-11 07:47:33 +00:00
|
|
|
def new
|
2014-05-09 08:42:23 +00:00
|
|
|
@ad_banner = Banner.new
|
|
|
|
render layout: false
|
2014-04-11 07:47:33 +00:00
|
|
|
end
|
2014-05-09 08:42:23 +00:00
|
|
|
|
2014-04-11 07:47:33 +00:00
|
|
|
def create
|
2014-05-09 08:42:23 +00:00
|
|
|
@ad_banner = Banner.new(banner_params)
|
|
|
|
if @ad_banner.save
|
|
|
|
redirect_to admin_ad_banners_url
|
|
|
|
else
|
|
|
|
@ad_banner = Banner.new(params[:ad_banner])
|
|
|
|
render :new
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def edit
|
|
|
|
@ad_banner = Banner.find(params[:id])
|
|
|
|
render layout: false
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
|
|
|
@ad_banner = Banner.find(params[:id])
|
|
|
|
if @ad_banner.update_attributes(banner_params)
|
|
|
|
redirect_to admin_ad_banners_url, :status => 303
|
|
|
|
else
|
|
|
|
render :edit
|
|
|
|
end
|
2014-04-11 07:47:33 +00:00
|
|
|
end
|
|
|
|
|
2014-05-09 08:42:23 +00:00
|
|
|
def destroy
|
|
|
|
@ad_banner = Banner.find(params[:id])
|
|
|
|
@ad_banner.destroy
|
|
|
|
redirect_to admin_ad_banners_url
|
|
|
|
end
|
|
|
|
|
2014-04-11 07:47:33 +00:00
|
|
|
private
|
|
|
|
|
|
|
|
# Never trust parameters from the scary internet, only allow the white list through.
|
|
|
|
def banner_params
|
2014-05-09 08:42:23 +00:00
|
|
|
params.require(:ad_banner).permit!
|
2014-04-11 07:47:33 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|