Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev to release fixes #236

Merged
merged 2 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions core/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
set_user_password,
)
from core.tasks import openimis_mutation_async
from core import filter_validity
from django import dispatch
from django.conf import settings
from django.contrib.auth.models import AnonymousUser
Expand Down Expand Up @@ -660,8 +661,9 @@ def resolve_users(self, info, email=None, last_name=None, other_names=None, phon

show_deleted = kwargs.get('showDeleted', False)
if not show_deleted and not kwargs.get('id', None):
active_users_ids = [user.id for user in user_query if user.is_active]
user_filters.append(Q(id__in=active_users_ids))

#active_users_ids = [user.id for user in user_query if user.is_active]
user_filters.append(Q(i_user__isnull=True) | Q(*filter_validity(prefix='i_user')))

text_search = kwargs.get("str") # Poorly chosen name, avoid of shadowing "str"
if text_search:
Expand Down
10 changes: 5 additions & 5 deletions core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,16 @@ def __ne__(self, other):
return cls


def filter_validity(arg="validity", **kwargs):
def filter_validity(arg="validity", prefix = '', **kwargs):
validity = kwargs.get(arg)
if validity is None:
return (
Q(legacy_id__isnull=True),
Q(validity_to__isnull=True),
Q(**{f'{prefix}legacy_id__isnull':True}),
Q(**{f'{prefix}validity_to__isnull':True})
)
return (
Q(validity_from__lte=validity),
Q(validity_to__isnull=True) | Q(validity_to__gte=validity),
Q(**{f'{prefix}validity_from__lte':validity}),
Q(**{f'{prefix}validity_to__isnull':True}) | Q(**{f'{prefix}validity_to__gte':validity})
)


Expand Down
Loading