Sha256: 81b529b1dac1cd64d78317dd154a7f276203a4a47ad163432ca4fad7f846ecbd

Contents?: true

Size: 874 Bytes

Versions: 9

Compression:

Stored size: 874 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module DecidimAwesome
    class Permissions < Decidim::DefaultPermissions
      def permissions
        return permission_action unless user

        return Decidim::DecidimAwesome::Admin::Permissions.new(user, permission_action, context).permissions if permission_action.scope == :admin

        editor_image_action?

        permission_action
      end

      def editor_image_action?
        return unless permission_action.subject == :editor_image

        config = context.fetch(:awesome_config, {})

        return allow! if config[:allow_images_in_proposals]

        if user.admin
          return allow! if config[:allow_images_in_small_editor]
          return allow! if config[:allow_images_in_full_editor]
          return allow! if config[:allow_images_in_markdown_editor]
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
decidim-decidim_awesome-0.8.3 app/permissions/decidim/decidim_awesome/permissions.rb
decidim-decidim_awesome-0.8.2 app/permissions/decidim/decidim_awesome/permissions.rb
decidim-decidim_awesome-0.8.1 app/permissions/decidim/decidim_awesome/permissions.rb
decidim-decidim_awesome-0.8.0 app/permissions/decidim/decidim_awesome/permissions.rb
decidim-decidim_awesome-0.7.2 app/permissions/decidim/decidim_awesome/permissions.rb
decidim-decidim_awesome-0.7.0 app/permissions/decidim/decidim_awesome/permissions.rb
decidim-decidim_awesome-0.6.7 app/permissions/decidim/decidim_awesome/permissions.rb
decidim-decidim_awesome-0.6.6 app/permissions/decidim/decidim_awesome/permissions.rb
decidim-decidim_awesome-0.6.5 app/permissions/decidim/decidim_awesome/permissions.rb