Sha256: 4d5da682553d67f8027c81b4d06bd626d4d368b5fbce8969446ffa6d6b560479

Contents?: true

Size: 850 Bytes

Versions: 17

Compression:

Stored size: 850 Bytes

Contents

# frozen_string_literal: true

# generado con pg_rails

class UserPolicy < ApplicationPolicy
  class Scope < ApplicationPolicy::Scope
    def resolve
      if Current.namespace == :admin
        scope.all
      elsif Current.account.present?
        ids = Current.account.user_accounts.ua_active.pluck(:user_id)
        scope.where(id: ids)
      else
        scope.none
      end
    end
  end

  # def puede_editar?
  #   acceso_total? && !record.readonly?
  # end

  # def puede_crear?
  #   acceso_total? || user.asesor?
  # end

  # def puede_borrar?
  #   acceso_total? && !record.readonly?
  # end
  def puede_editar?
    base_access_to_record?
  end

  def new_from_associable?
    false
  end

  def base_access_to_record?
    Current.namespace == :admin || user == record
  end

  def base_access_to_collection?
    user.present?
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
pg_rails-7.6.23 pg_engine/app/policies/user_policy.rb
pg_rails-7.6.22 pg_engine/app/policies/user_policy.rb
pg_rails-7.6.22.pre.3 pg_engine/app/policies/user_policy.rb
pg_rails-7.6.22.pre.2 pg_engine/app/policies/user_policy.rb
pg_rails-7.6.22.pre.1 pg_engine/app/policies/user_policy.rb
pg_rails-7.6.21 pg_engine/app/policies/user_policy.rb
pg_rails-7.6.21.pre.11 pg_engine/app/policies/user_policy.rb
pg_rails-7.6.21.pre.10 pg_engine/app/policies/user_policy.rb
pg_rails-7.6.21.pre.9 pg_engine/app/policies/user_policy.rb
pg_rails-7.6.21.pre.8 pg_engine/app/policies/user_policy.rb
pg_rails-7.6.21.pre.7 pg_engine/app/policies/user_policy.rb
pg_rails-7.6.21.pre.6 pg_engine/app/policies/user_policy.rb
pg_rails-7.6.21.pre.5 pg_engine/app/policies/user_policy.rb
pg_rails-7.6.21.pre.4 pg_engine/app/policies/user_policy.rb
pg_rails-7.6.21.pre.3 pg_engine/app/policies/user_policy.rb
pg_rails-7.6.21.pre.2 pg_engine/app/policies/user_policy.rb
pg_rails-7.6.21.pre.1 pg_engine/app/policies/user_policy.rb