Sha256: 17e3235d413d4e2a94bc165c7cc054d3fcfda0154a2ebdea6a2ba6f80d7f0d6d

Contents?: true

Size: 1.3 KB

Versions: 295

Compression:

Stored size: 1.3 KB

Contents

module Caboose
  class MediaCategoriesController < ApplicationController

    # POST /admin/media-categories
    def admin_add
      return unless user_is_allowed('mediacategories', 'add')

      resp = Caboose::StdClass.new
      
      cat = MediaCategory.new(
        :site_id   => @site.id,
        :parent_id => params[:parent_id],
        :name      => params[:name]
      )      
      if !cat.save
        resp.error = cat.errors.first[1]
      else
        resp.refresh = true
      end
     
      render :json => resp
    end
    
    # PUT /admin/media-categories/:id
    def admin_update
      return unless user_is_allowed('mediacategories', 'edit')
      
      resp = StdClass.new
      cat = MediaCategory.find(params[:id])
      
      save = true      
      params.each do |name, value|
        case name          
          when 'name' then cat.name = value            
        end
      end
    
      resp.success = save && cat.save
      render :json => resp
    end
    
    # DELETE /admin/media-categories/:id
    def admin_delete
      return unless user_is_allowed('mediacategories', 'delete')
      cat = MediaCategory.find(params[:id])
      cat.destroy
      
      resp = StdClass.new({
        'redirect' => '/admin/media-categories'
      })
      render :json => resp
    end       
		
  end
end

Version data entries

295 entries across 295 versions & 1 rubygems

Version Path
caboose-cms-0.5.221 app/controllers/caboose/media_categories_controller.rb
caboose-cms-0.5.220 app/controllers/caboose/media_categories_controller.rb
caboose-cms-0.5.219 app/controllers/caboose/media_categories_controller.rb
caboose-cms-0.5.218 app/controllers/caboose/media_categories_controller.rb
caboose-cms-0.5.217 app/controllers/caboose/media_categories_controller.rb
caboose-cms-0.5.216 app/controllers/caboose/media_categories_controller.rb
caboose-cms-0.5.215 app/controllers/caboose/media_categories_controller.rb
caboose-cms-0.5.214 app/controllers/caboose/media_categories_controller.rb
caboose-cms-0.5.213 app/controllers/caboose/media_categories_controller.rb
caboose-cms-0.5.212 app/controllers/caboose/media_categories_controller.rb
caboose-cms-0.5.211 app/controllers/caboose/media_categories_controller.rb
caboose-cms-0.5.210 app/controllers/caboose/media_categories_controller.rb
caboose-cms-0.5.209 app/controllers/caboose/media_categories_controller.rb
caboose-cms-0.5.208 app/controllers/caboose/media_categories_controller.rb
caboose-cms-0.5.207 app/controllers/caboose/media_categories_controller.rb
caboose-cms-0.5.206 app/controllers/caboose/media_categories_controller.rb
caboose-cms-0.5.205 app/controllers/caboose/media_categories_controller.rb
caboose-cms-0.5.204 app/controllers/caboose/media_categories_controller.rb
caboose-cms-0.5.203 app/controllers/caboose/media_categories_controller.rb
caboose-cms-0.5.202 app/controllers/caboose/media_categories_controller.rb