mirror of https://github.com/zulip/zulip.git
send_custom_email: Pass realm as arg to select_related.
This commit updates the select_related calls in queries to get UserProfile objects in send_custom_email code to pass "realm" as argument to select_related call. Also, note that "realm" is the only non-null foreign key field in UserProfile object, so select_related() was only fetching realm object previously as well. But we should still pass "realm" as argument in select_related call so that we can make sure that only required fields are selected in case we add more foreign keys to UserProfile in future.
This commit is contained in:
parent
3ae0b4f913
commit
577555e529
|
@ -129,7 +129,7 @@ class Command(ZulipBaseCommand):
|
||||||
# We need to do a new query because the `get_users` path
|
# We need to do a new query because the `get_users` path
|
||||||
# passes us a list rather than a QuerySet.
|
# passes us a list rather than a QuerySet.
|
||||||
users = (
|
users = (
|
||||||
UserProfile.objects.select_related()
|
UserProfile.objects.select_related("realm")
|
||||||
.filter(id__in=[u.id for u in users])
|
.filter(id__in=[u.id for u in users])
|
||||||
.exclude(
|
.exclude(
|
||||||
Q(tos_version=None) | Q(tos_version=UserProfile.TOS_VERSION_BEFORE_FIRST_LOGIN)
|
Q(tos_version=None) | Q(tos_version=UserProfile.TOS_VERSION_BEFORE_FIRST_LOGIN)
|
||||||
|
|
Loading…
Reference in New Issue