|
17 | 17 | User = get_user_model() |
18 | 18 |
|
19 | 19 |
|
20 | | -# For now there can be up to three levels of nested elements. |
21 | | -# E.g. a RepeatElement might contain a ColumnElement, which might contain a |
22 | | -# HeadingElement. |
23 | | -# However, later this number could be dynamic depending on the page itself. |
24 | | -MAX_ELEMENT_NESTING_DEPTH = 3 |
| 20 | +# Later this number could be dynamic but for now we set it arbitrary |
| 21 | +# high enough to cover most usages. |
| 22 | +MAX_ELEMENT_NESTING_DEPTH = 9 |
25 | 23 |
|
26 | 24 |
|
27 | 25 | class ElementVisibilityPermissionManager(PermissionManagerType): |
@@ -182,11 +180,13 @@ def exclude_elements_with_page_visibility( |
182 | 180 | return queryset.exclude(page__visibility=Page.VISIBILITY_TYPES.LOGGED_IN) |
183 | 181 |
|
184 | 182 | return queryset.exclude( |
185 | | - page__role_type=Page.ROLE_TYPES.ALLOW_ALL_EXCEPT, |
186 | | - page__roles__contains=actor.role, |
| 183 | + Q(page__visibility=Page.VISIBILITY_TYPES.LOGGED_IN) |
| 184 | + & Q(page__role_type=Page.ROLE_TYPES.ALLOW_ALL_EXCEPT) |
| 185 | + & Q(page__roles__contains=[actor.role]) |
187 | 186 | ).exclude( |
188 | | - Q(page__role_type=Page.ROLE_TYPES.DISALLOW_ALL_EXCEPT) |
189 | | - & ~Q(page__roles__contains=actor.role), |
| 187 | + Q(page__visibility=Page.VISIBILITY_TYPES.LOGGED_IN) |
| 188 | + & Q(page__role_type=Page.ROLE_TYPES.DISALLOW_ALL_EXCEPT) |
| 189 | + & ~Q(page__roles__contains=[actor.role]), |
190 | 190 | ) |
191 | 191 |
|
192 | 192 | def exclude_elements_with_visibility( |
|
0 commit comments