Sha256: e5df23bb2ac1c1bbe40ed5516b1cdf48d0ccd378513f0697d98149fa53d0ecde

Contents?: true

Size: 718 Bytes

Versions: 27

Compression:

Stored size: 718 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Debates
    module Admin
      class Permissions < Decidim::DefaultPermissions
        def permissions
          # The public part needs to be implemented yet
          return permission_action if permission_action.scope != :admin
          return permission_action if permission_action.subject != :debate

          case permission_action.action
          when :create, :read
            allow!
          when :update, :delete
            toggle_allow(debate && debate.official?)
          end

          permission_action
        end

        private

        def debate
          @debate ||= context.fetch(:debate, nil)
        end
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
decidim-debates-0.22.0 app/permissions/decidim/debates/admin/permissions.rb
decidim-debates-0.21.0 app/permissions/decidim/debates/admin/permissions.rb
decidim-debates-0.20.1 app/permissions/decidim/debates/admin/permissions.rb
decidim-debates-0.20.0 app/permissions/decidim/debates/admin/permissions.rb
decidim-debates-0.19.1 app/permissions/decidim/debates/admin/permissions.rb
decidim-debates-0.18.1 app/permissions/decidim/debates/admin/permissions.rb
decidim-debates-0.19.0 app/permissions/decidim/debates/admin/permissions.rb
decidim-debates-0.17.2 app/permissions/decidim/debates/admin/permissions.rb
decidim-debates-0.18.0 app/permissions/decidim/debates/admin/permissions.rb
decidim-debates-0.17.1 app/permissions/decidim/debates/admin/permissions.rb
decidim-debates-0.16.1 app/permissions/decidim/debates/admin/permissions.rb
decidim-debates-0.17.0 app/permissions/decidim/debates/admin/permissions.rb
decidim-debates-0.16.0 app/permissions/decidim/debates/admin/permissions.rb
decidim-debates-0.15.2 app/permissions/decidim/debates/admin/permissions.rb
decidim-debates-0.15.1 app/permissions/decidim/debates/admin/permissions.rb
decidim-debates-0.15.0 app/permissions/decidim/debates/admin/permissions.rb
decidim-debates-0.14.4 app/permissions/decidim/debates/admin/permissions.rb
decidim-debates-0.14.3 app/permissions/decidim/debates/admin/permissions.rb
decidim-debates-0.14.2 app/permissions/decidim/debates/admin/permissions.rb
decidim-debates-0.14.1 app/permissions/decidim/debates/admin/permissions.rb