File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,11 @@ class PhotoAlbum < ApplicationRecord
99 validates :publicly_visible , inclusion : [ true , false ]
1010
1111 scope :publicly_visible , ( -> { where ( publicly_visible : true ) } )
12+ scope :posted_between_or_publicly_visible , ( lambda { |start_date , end_date |
13+ where ( publicly_visible : true )
14+ . or ( where . not ( date : nil ) . where ( date : start_date ..end_date ) )
15+ . or ( where ( date : nil ) . where ( created_at : start_date ..end_date ) )
16+ } )
1217
1318 def owners
1419 if group . present?
Original file line number Diff line number Diff line change 11class PhotoAlbumPolicy < ApplicationPolicy
22 class Scope < ApplicationPolicy ::Scope
3- def resolve
3+ def resolve # rubocop:disable Metrics/AbcSize
44 if user_can_read?
5- scope
5+ membership = user . memberships . joins ( :group ) . where ( groups : { name : 'Leden' } ) . first
6+ return scope . publicly_visible if membership . nil?
7+
8+ scope . posted_between_or_publicly_visible (
9+ membership . start_date &.advance ( months : -18 ) ,
10+ membership . end_date &.advance ( months : 6 )
11+ )
612 else
713 scope . publicly_visible
814 end
You can’t perform that action at this time.
0 commit comments