Sha256: d675d5abdd10abe7ddae99cf1dd8fb10cf164b35947476cfc2b596d3b0f2a899

Contents?: true

Size: 1.46 KB

Versions: 50

Compression:

Stored size: 1.46 KB

Contents

module Caboose
  class PageBlockFieldValuesController < ApplicationController
    
    # PUT /admin/page-block-field-values/:id
    def admin_update
      return unless user_is_allowed('pages', 'edit')
      
      resp = StdClass.new({'attributes' => {}})
      fv = PageBlockFieldValue.find(params[:id])
                  
      save = true
      user = logged_in_user      
      
      params.each do |k,v|
        case k
          when 'value'
            fv.value = v                                
        end
      end      
               
      resp.success = save && fv.save
      render :json => resp
    end
    
    # POST /admin/page-block-field-values/:id/image
    def admin_update_image
      return unless user_is_allowed('pages', 'edit')
      
      resp = StdClass.new({'attributes' => {}})
      fv = PageBlockFieldValue.find(params[:id])
      fv.image = params[:value]
      fv.save
      resp.success = true 
      resp.attributes = { 'value' => { 'value' => fv.image.url(:tiny) }}
      
      render :json => resp
    end
    
    # POST /admin/page-block-field-values/:id/file
    def admin_update_file
      return unless user_is_allowed('pages', 'edit')
      
      resp = StdClass.new({'attributes' => {}})
      fv = PageBlockFieldValue.find(params[:id])
      fv.file = params[:value]
      fv.save
      resp.success = true      
      resp.attributes = { 'value' => { 'value' => fv.file.url }}
      
      render :json => resp
    end
		
  end  
end

Version data entries

50 entries across 50 versions & 1 rubygems

Version Path
caboose-cms-0.3.129 app/controllers/caboose/page_block_field_values_controller.rb
caboose-cms-0.3.128 app/controllers/caboose/page_block_field_values_controller.rb
caboose-cms-0.3.127 app/controllers/caboose/page_block_field_values_controller.rb
caboose-cms-0.3.110 app/controllers/caboose/page_block_field_values_controller.rb
caboose-cms-0.3.101 app/controllers/caboose/page_block_field_values_controller.rb
caboose-cms-0.3.100 app/controllers/caboose/page_block_field_values_controller.rb
caboose-cms-0.3.99 app/controllers/caboose/page_block_field_values_controller.rb
caboose-cms-0.3.98 app/controllers/caboose/page_block_field_values_controller.rb
caboose-cms-0.3.97 app/controllers/caboose/page_block_field_values_controller.rb
caboose-cms-0.3.96 app/controllers/caboose/page_block_field_values_controller.rb
caboose-cms-0.3.95 app/controllers/caboose/page_block_field_values_controller.rb
caboose-cms-0.3.94 app/controllers/caboose/page_block_field_values_controller.rb
caboose-cms-0.3.93 app/controllers/caboose/page_block_field_values_controller.rb
caboose-cms-0.3.92 app/controllers/caboose/page_block_field_values_controller.rb
caboose-cms-0.3.91 app/controllers/caboose/page_block_field_values_controller.rb
caboose-cms-0.3.90 app/controllers/caboose/page_block_field_values_controller.rb
caboose-cms-0.3.89 app/controllers/caboose/page_block_field_values_controller.rb
caboose-cms-0.3.88 app/controllers/caboose/page_block_field_values_controller.rb
caboose-cms-0.3.87 app/controllers/caboose/page_block_field_values_controller.rb
caboose-cms-0.3.86 app/controllers/caboose/page_block_field_values_controller.rb