Sha256: e6a380dc1d051234315fb77a6291e9e8dfbf32ff7e683f4a2b229f0c86805e96

Contents?: true

Size: 1.16 KB

Versions: 48

Compression:

Stored size: 1.16 KB

Contents

require 'scrivito/cms_field_tag'
require 'fiona7/permitted_mixin'

module Scrivito
  class CmsFieldTag
    include Fiona7::PermittedMixin

    # support shadowclassing
    def build_valid_widget_classes
      obj_or_widget.valid_widget_ruby_classes_for(field_name).map do |widget_class|
        real_widget_class_name = widget_class.name
        fake_widget_class = widget_class.to_s
        widget_class = widget_class.to_s
        {
          name: fake_widget_class,
          description: description_for_widget_class(real_widget_class_name),
        }
      end
    end


    private
    # add permission checking
    def authenticated_editor?
      editing_context.authenticated_editor? &&
        (permitted?(editing_context.editor.id, obj_not_widget_id, :root) ||
         permitted?(editing_context.editor.id, obj_not_widget_id, :write))
    end

    def obj_not_widget_id
      case obj_or_widget
      when Scrivito::BasicObj
        obj_or_widget.id
      when Scrivito::BasicWidget
        obj_or_widget.obj.id
      else
        raise ScrivitoError, "Expected an Obj or Widget to be passed to scrivito_tag, but #{obj_or_widget.class.name} received"
      end
    end
  end
end

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
infopark_fiona7-1.2.0.2.3 lib/fiona7/scrivito_patches/cms_field_tag.rb
infopark_fiona7-1.2.0.2.1 lib/fiona7/scrivito_patches/cms_field_tag.rb
infopark_fiona7-1.2.0.2.2 lib/fiona7/scrivito_patches/cms_field_tag.rb
infopark_fiona7-1.5.5.5.1 lib/fiona7/scrivito_patches/cms_field_tag.rb
infopark_fiona7-1.5.5.5.0 lib/fiona7/scrivito_patches/cms_field_tag.rb
infopark_fiona7-1.2.0.1.4 lib/fiona7/scrivito_patches/cms_field_tag.rb
infopark_fiona7-1.5.5.4.1 lib/fiona7/scrivito_patches/cms_field_tag.rb
infopark_fiona7-1.5.5.4.0 lib/fiona7/scrivito_patches/cms_field_tag.rb
infopark_fiona7-1.2.0.1.3 lib/fiona7/scrivito_patches/cms_field_tag.rb
infopark_fiona7-1.5.5.3.1 lib/fiona7/scrivito_patches/cms_field_tag.rb
infopark_fiona7-1.5.4.3.0 lib/fiona7/scrivito_patches/cms_field_tag.rb
infopark_fiona7-1.5.3.2.0 lib/fiona7/scrivito_patches/cms_field_tag.rb
infopark_fiona7-1.5.3.2.0.pre.beta1 lib/fiona7/scrivito_patches/cms_field_tag.rb
infopark_fiona7-1.5.2.1.0.pre.beta1 lib/fiona7/scrivito_patches/cms_field_tag.rb
infopark_fiona7-1.5.2.0.0 lib/fiona7/scrivito_patches/cms_field_tag.rb
infopark_fiona7-1.2.0.1.1 lib/fiona7/scrivito_patches/cms_field_tag.rb
infopark_fiona7-1.2.0.0.1 lib/fiona7/scrivito_patches/cms_field_tag.rb
infopark_fiona7-1.2.0.0.0 lib/fiona7/scrivito_patches/cms_field_tag.rb
infopark_fiona7-1.1.0.0.9 lib/fiona7/scrivito_patches/cms_field_tag.rb
infopark_fiona7-1.1.0.0.8 lib/fiona7/scrivito_patches/cms_field_tag.rb