Class: Admin::AdUnitsController
- Inherits:
-
AdminController
- Object
- AdminController
- Admin::AdUnitsController
- Defined in:
- app/controllers/admin/ad_units_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #create_block ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'app/controllers/admin/ad_units_controller.rb', line 32 def create @ad_unit = AdUnit.new(params[:ad_unit]) @ad_unit.system_id = _sid if @ad_unit.save Activity.add(_sid, "Ad Unit '#{@ad_unit.name}' created", current_user.id, "Ads", '') redirect_to [:admin, @ad_unit], :notice => "Successfully created Ad Unit" else render :action => 'new' end end |
#create_block ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'app/controllers/admin/ad_units_controller.rb', line 5 def create_block @ad_unit = AdUnit.find_sys_id(_sid, params[:id]) block = Block.sys(_sid).where(:name=>@ad_unit.block_name).first if block notice = 'Block already exists' else block = Block.create(:system_id=>_sid, :name=>@ad_unit.block_name, :description=>"System generated block to display an ad of size '#{@ad_unit.name}'", :show_editors=>true, :all_templates=>true, :user_id=>current_user.id, :body=>"<% if params[:edit] %>[[ad will appear here]]<% else %><% ad = kit_ad_by_unit(#{@ad_unit.id}) %><%= kit_ad(ad.id) if ad %><% end %>") notice = 'Block created' end redirect_to [:admin, @ad_unit], :notice=>notice end |
#destroy ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'app/controllers/admin/ad_units_controller.rb', line 57 def destroy @ad_unit = AdUnit.find_sys_id(_sid, params[:id]) if @ad_unit.ad_zones.count > 0 redirect_to admin_ad_units_url, :notice=>"Cannot delete whilst Ad Zones are using this unit" and return end Activity.add(_sid, "Ad Unit '#{@ad_unit.name}' deleted", current_user.id, "Ads", '') @ad_unit.destroy redirect_to admin_ad_units_url, :notice => "Successfully deleted Ad Unit" end |
#edit ⇒ Object
43 44 45 |
# File 'app/controllers/admin/ad_units_controller.rb', line 43 def edit @ad_unit = AdUnit.find_sys_id(_sid, params[:id]) end |
#index ⇒ Object
20 21 22 |
# File 'app/controllers/admin/ad_units_controller.rb', line 20 def index @ad_units = AdUnit.sys(_sid).all end |
#new ⇒ Object
28 29 30 |
# File 'app/controllers/admin/ad_units_controller.rb', line 28 def new @ad_unit = AdUnit.new end |
#show ⇒ Object
24 25 26 |
# File 'app/controllers/admin/ad_units_controller.rb', line 24 def show @ad_unit = AdUnit.find_sys_id(_sid, params[:id]) end |
#update ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'app/controllers/admin/ad_units_controller.rb', line 47 def update @ad_unit = AdUnit.find_sys_id(_sid, params[:id]) if @ad_unit.update_attributes(params[:ad_unit]) Activity.add(_sid, "Ad Unit '#{@ad_unit.name}' updated", current_user.id, "Ads", '') redirect_to [:admin, @ad_unit], :notice => "Successfully updated Ad Unit" else render :action => 'edit' end end |