| 
									
										
										
										
											2012-11-20 07:47:07 +00:00
										 |  |  | class Admin::AdImagesController < Admin::AdBannersController | 
					
						
							| 
									
										
										
										
											2013-10-18 07:25:19 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   before_filter :only => [ :new, :edit ] do | 
					
						
							|  |  |  |     @ad_banners = AdBanner.all | 
					
						
							|  |  |  |     @tags = get_tags | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-20 07:47:07 +00:00
										 |  |  |   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-10-18 07:25:19 +00:00
										 |  |  |     @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_image = AdImage.find(params[:id]) | 
					
						
							| 
									
										
										
										
											2012-04-01 15:39:49 +00:00
										 |  |  |   end | 
					
						
							|  |  |  |    | 
					
						
							|  |  |  |   def update | 
					
						
							| 
									
										
										
										
											2013-10-18 07:25:19 +00:00
										 |  |  |     @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 | 
					
						
							| 
									
										
										
										
											2012-04-01 15:39:49 +00:00
										 |  |  |   end | 
					
						
							|  |  |  |    | 
					
						
							| 
									
										
										
										
											2013-10-18 07:25:19 +00:00
										 |  |  |   def new  | 
					
						
							| 
									
										
										
										
											2013-08-09 01:24:26 +00:00
										 |  |  |     @ad_image = AdImage.new | 
					
						
							| 
									
										
										
										
											2013-10-18 07:25:19 +00:00
										 |  |  |     @ad_image.postdate = Date.today | 
					
						
							|  |  |  |     @ad_image.deadline = Date.today + 30
 | 
					
						
							| 
									
										
										
										
											2012-04-01 15:39:49 +00:00
										 |  |  |   end | 
					
						
							|  |  |  |    | 
					
						
							|  |  |  |   def create | 
					
						
							| 
									
										
										
										
											2013-10-18 07:25:19 +00:00
										 |  |  |     @ad_image = AdImage.new(params[:ad_image]) | 
					
						
							| 
									
										
										
										
											2013-08-09 01:24:26 +00:00
										 |  |  |     if @ad_image.save | 
					
						
							| 
									
										
										
										
											2013-10-18 07:25:19 +00:00
										 |  |  |       redirect_to admin_ad_images_url | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |       @ad_banners = AdBanner.all | 
					
						
							|  |  |  |       @tags = get_tags | 
					
						
							|  |  |  |       @ad_image = AdImage.new(params[:ad_image]) | 
					
						
							|  |  |  |       render action: :new | 
					
						
							| 
									
										
										
										
											2012-04-01 15:39:49 +00:00
										 |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  |    | 
					
						
							|  |  |  |   def destroy | 
					
						
							| 
									
										
										
										
											2013-08-09 01:24:26 +00:00
										 |  |  |     @ad_image = AdImage.find params[:id] | 
					
						
							| 
									
										
										
										
											2012-04-01 15:39:49 +00:00
										 |  |  |     if @ad_image.destroy | 
					
						
							| 
									
										
										
										
											2013-10-18 07:25:19 +00:00
										 |  |  |       redirect_to admin_ad_images_url | 
					
						
							| 
									
										
										
										
											2012-04-01 15:39:49 +00:00
										 |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  |    | 
					
						
							|  |  |  |    | 
					
						
							|  |  |  | end |