59 lines
1.1 KiB
Ruby
59 lines
1.1 KiB
Ruby
class Admin::AdImagesController < Admin::AdBannersController
|
|
|
|
before_filter :only => [ :new, :edit ] do
|
|
@ad_banners = AdBanner.all
|
|
@tags = get_tags
|
|
end
|
|
|
|
def initialize
|
|
super
|
|
@app_title = "ad_banner"
|
|
end
|
|
|
|
def index
|
|
@ad_images = get_sorted_and_filtered("ad_image")
|
|
end
|
|
|
|
def edit
|
|
@ad_image = AdImage.find(params[:id])
|
|
end
|
|
|
|
def update
|
|
@ad_image = AdImage.find(params[:id])
|
|
if @ad_image.update_attributes(params[:ad_image])
|
|
redirect_to admin_ad_images_url
|
|
else
|
|
@ad_banners = AdBanner.all
|
|
@tags = get_tags
|
|
render action: :edit
|
|
end
|
|
end
|
|
|
|
def new
|
|
@ad_image = AdImage.new
|
|
@ad_image.postdate = Date.today
|
|
@ad_image.deadline = Date.today + 30
|
|
end
|
|
|
|
def create
|
|
@ad_image = AdImage.new(params[:ad_image])
|
|
if @ad_image.save
|
|
redirect_to admin_ad_images_url
|
|
else
|
|
@ad_banners = AdBanner.all
|
|
@tags = get_tags
|
|
@ad_image = AdImage.new(params[:ad_image])
|
|
render action: :new
|
|
end
|
|
end
|
|
|
|
def destroy
|
|
@ad_image = AdImage.find params[:id]
|
|
if @ad_image.destroy
|
|
redirect_to admin_ad_images_url
|
|
end
|
|
end
|
|
|
|
|
|
end
|