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.181 app/controllers/caboose/media_categories_controller.rb
caboose-cms-0.5.180 app/controllers/caboose/media_categories_controller.rb
caboose-cms-0.5.179 app/controllers/caboose/media_categories_controller.rb
caboose-cms-0.5.178 app/controllers/caboose/media_categories_controller.rb
caboose-cms-0.5.177 app/controllers/caboose/media_categories_controller.rb
caboose-cms-0.5.176 app/controllers/caboose/media_categories_controller.rb
caboose-cms-0.5.175 app/controllers/caboose/media_categories_controller.rb
caboose-cms-0.5.174 app/controllers/caboose/media_categories_controller.rb
caboose-cms-0.5.173 app/controllers/caboose/media_categories_controller.rb
caboose-cms-0.5.172 app/controllers/caboose/media_categories_controller.rb
caboose-cms-0.5.171 app/controllers/caboose/media_categories_controller.rb
caboose-cms-0.5.170 app/controllers/caboose/media_categories_controller.rb
caboose-cms-0.5.169 app/controllers/caboose/media_categories_controller.rb
caboose-cms-0.5.168 app/controllers/caboose/media_categories_controller.rb
caboose-cms-0.5.167 app/controllers/caboose/media_categories_controller.rb
caboose-cms-0.5.166 app/controllers/caboose/media_categories_controller.rb
caboose-cms-0.5.165 app/controllers/caboose/media_categories_controller.rb
caboose-cms-0.5.164 app/controllers/caboose/media_categories_controller.rb
caboose-cms-0.5.163 app/controllers/caboose/media_categories_controller.rb
caboose-cms-0.5.162 app/controllers/caboose/media_categories_controller.rb