Skip to content

Commit

Permalink
fix: autocomplete when trainer marks attendance
Browse files Browse the repository at this point in the history
  • Loading branch information
fivan999 committed Jan 27, 2025
1 parent 1da3ac6 commit 25df542
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions adminpage/api/crud/crud_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,13 @@ def get_email_name_like_students(pattern: str, limit: int = 5, requirement=~Q(pk
'medical_group__name',
'gender'
)[:limit]

return list(query)


def get_email_name_like_students_filtered_by_group(pattern: str, limit: int = 5, group=None):
group = Group.objects.get(id=group)
# Don't suggest the student that is in 'Banned students' list
not_banned_condition = ~Q(pk__in=group.banned_students.values_list('id', flat=True))
not_banned_condition = ~Q(user_id__in=group.banned_students.values_list('user_id', flat=True))
# The student must either be in 'Allowed students' list, or have acceptable medical group
allowed_condition = Q(pk__in=group.allowed_students.values_list('id', flat=True)) | Q(medical_group__in=group.allowed_medical_groups.all())
allowed_condition = Q(user_id__in=group.allowed_students.values_list('user_id', flat=True)) | Q(medical_group__in=group.allowed_medical_groups.all())
return get_email_name_like_students(pattern, limit, not_banned_condition & allowed_condition)

0 comments on commit 25df542

Please sign in to comment.