Skip to content

Commit

Permalink
Update filter editable scope
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomáš Durčák committed Sep 16, 2024
1 parent ab4b919 commit 6afd341
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions app/models/filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ class Filter < ApplicationRecord

scope :pinned, -> { where(is_pinned: true) }
scope :not_pinned, -> { where(is_pinned: false) }
scope :visible_for, -> (user) { joins(:user_filter_visibilities)
.where(user_filter_visibilities: { visible: true, user: user})
.where(is_pinned: false) }

acts_as_list scope: :tenant_id

Expand Down
2 changes: 1 addition & 1 deletion app/policies/filter_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def initialize(user, filter)

class ScopeEditable < Scope
def resolve
scoped = scope.where(tenant_id: Current.tenant)
scoped = scope.where(tenant_id: Current.tenant).visible_for(@user)

return scoped if @user.admin?

Expand Down

0 comments on commit 6afd341

Please sign in to comment.