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