Skip to content

Commit

Permalink
Haystack3/Elasticsearch7 SearchQueryset changes #2
Browse files Browse the repository at this point in the history
SQS BooleanField properties are now checked with string "true"/"false" instead of bool True/False
  • Loading branch information
saschasommer committed Mar 14, 2023
1 parent 66b6ba2 commit 4fd9c74
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions cosinnus/forms/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,24 @@ def filter_searchqueryset_for_read_access(sqs, user):
result set to only include elements with read access.
"""
public_node = (
SQ(public__exact=True) | # public on the object itself (applicable for groups)
SQ(public__exact="true") | # public on the object itself (applicable for groups)
SQ(mt_visibility__exact=BaseTagObject.VISIBILITY_ALL) | # public via "everyone can see me" visibility meta attribute
SQ(always_visible__exact=True) # special marker for indexed objects that should always show up in search
SQ(always_visible__exact="true") # special marker for indexed objects that should always show up in search
)

if user.is_authenticated:
if check_user_superuser(user):
pass
else:
logged_in_user_visibility = (
SQ(user_visibility_mode__exact=True) & # for UserProfile search index objects
SQ(user_visibility_mode__exact="true") & # for UserProfile search index objects
SQ(mt_visibility__exact=BaseTagObject.VISIBILITY_GROUP) # logged in users can see users who are visible
)
my_item = (
SQ(creator__exact=user.id)
)
visible_for_all_authenticated_users = (
SQ(visible_for_all_authenticated_users=True)
SQ(visible_for_all_authenticated_users="true")
)
# FIXME: known problem: ``group_members`` is a stale indexed representation of the members
# of an items group. New members of a group won't be able to find old indexed items if the index
Expand All @@ -82,7 +82,7 @@ def filter_searchqueryset_for_read_access(sqs, user):
users_group_ids = get_cosinnus_group_model().objects.get_for_user_pks(user)
if True:
group_member_user_visibility = (
SQ(user_visibility_mode__exact=True) & # for UserProfile search index objects
SQ(user_visibility_mode__exact="true") & # for UserProfile search index objects
SQ(mt_visibility__exact=BaseTagObject.VISIBILITY_USER) & # team mambers can see this user
SQ(membership_groups__in=users_group_ids)
)
Expand Down
4 changes: 2 additions & 2 deletions cosinnus/views/map_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ def get_queryset(self, filter_group_id=None):

# filter all default user groups if the new dashboard is being used (they count as "on plattform" and aren't shown)
if getattr(settings, 'COSINNUS_USE_V2_DASHBOARD', False):
sqs = sqs.exclude(is_group_model=True, slug__in=get_default_user_group_slugs())
sqs = sqs.exclude(is_group_model="true", slug__in=get_default_user_group_slugs())

prefer_own_portal = getattr(settings, 'MAP_API_HACKS_PREFER_OWN_PORTAL', False)
# if we have no query-boosted results, use *only* our custom sorting (haystack's is very random)
Expand Down Expand Up @@ -405,7 +405,7 @@ def get_queryset_base(self, matching_result, filter_group_id=None):
'cosinnus_organization.cosinnusorganization',
))
# filter only candidates which are open for cooperation
sqs = sqs.filter(is_open_for_cooperation=True)
sqs = sqs.filter(is_open_for_cooperation="true")
# exclude matching candidate itself
sqs = sqs.exclude(_id=matching_result.id)
return sqs
Expand Down

0 comments on commit 4fd9c74

Please sign in to comment.