Use server side search for user fields - #2677
Conversation
richardebeling
left a comment
There was a problem hiding this comment.
Looks good, thanks. My biggest concern is that we need to find some descriptive terminology around this (and tests), otherwise just nits. Marking as draft until we have tests.
| self.fields["contributor"].queryset = self.get_contributor_queryset() | UserProfile.objects.filter( | ||
| pk=self.instance.contributor.pk | ||
| ) | ||
| self.fields["contributor"].widget.search_url = reverse("staff:fetch_contributor_user_profiles") |
There was a problem hiding this comment.
Does this mean that if you accidentally remove someone from the selection, you'll not be able to add them back?
How does TomSelect handle a mixture of HTML-supplied and server-supplied options? Does merge the server-options with the HTML options on an update, or will the HTML options be overwritten? If the former, maybe we can remove a large part of the specialization logic we have for "keep allowing existing participants" etc.
There was a problem hiding this comment.
The HTML options don't get overriden.
There was a problem hiding this comment.
Does this work then?
maybe we can remove a large part of the specialization logic we have for "keep allowing existing participants" etc.
I would imagine that if we just provide all current participants as in-HTML options, we can simplify the view logic drastically, leading to cacheability etc
|
I think this is very cool! I didn't have time to look at it closely yet, but now I will let you settle Richard's comments first :) |
1e35d6f to
1398755
Compare
| def get_participants_queryset(cls, evaluation: Evaluation | None) -> QuerySet[UserProfile]: | ||
| queryset = UserProfile.objects.exclude(is_active=False) | ||
| if evaluation is not None and evaluation.pk is not None: | ||
| queryset = (queryset | evaluation.participants.all()).distinct() |
There was a problem hiding this comment.
I had hoped we would not need this anymore (by just passing the initial options in HTML) -- why is this still needed here?
d69cc52 to
a6a4a08
Compare
a6a4a08 to
10719c9
Compare
10719c9 to
23734a6
Compare
niklasmohrin
left a comment
There was a problem hiding this comment.
("reviewing" to get this out of the queue, feel free to re-request)
Close #1681