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.13.1 app/permissions/decidim/debates/admin/permissions.rb
decidim-debates-0.12.2 app/permissions/decidim/debates/admin/permissions.rb
decidim-debates-0.13.0 app/permissions/decidim/debates/admin/permissions.rb
decidim-debates-0.12.1 app/permissions/decidim/debates/admin/permissions.rb
decidim-debates-0.13.0.pre1 app/permissions/decidim/debates/admin/permissions.rb
decidim-debates-0.12.0 app/permissions/decidim/debates/admin/permissions.rb
decidim-debates-0.12.0.pre app/permissions/decidim/debates/admin/permissions.rb