Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

support: Allow user look up through full name search.

Vishnu KSdd5bcb97e8a7
diff --git a/analytics/tests/test_views.py b/analytics/tests/test_views.py
index d027342d39a..2fed3edbe5f 100644
--- a/analytics/tests/test_views.py
+++ b/analytics/tests/test_views.py
@@ -440,6 +440,11 @@ class TestSupportEndpoint(ZulipTestCase):
'class="copy-button" data-copytext="[email protected], [email protected]"',
], result)
+ def check_othello_user_query_result(result: HttpResponse) -> None:
+ self.assert_in_success_response(['<span class="label">user</span>\n', '<h3>Othello, the Moor of Venice</h3>',
+ '<b>Email</b>: [email protected]', '<b>Is active</b>: True<br>'
+ ], result)
+
def check_zulip_realm_query_result(result: HttpResponse) -> None:
zulip_realm = get_realm("zulip")
self.assert_in_success_response([f'<input type="hidden" name="realm_id" value="{zulip_realm.id}"',
@@ -544,6 +549,15 @@ class TestSupportEndpoint(ZulipTestCase):
check_zulip_realm_query_result(result)
check_lear_realm_query_result(result)
+ result = self.client_get("/activity/support", {"q": "King hamlet,lear"})
+ check_hamlet_user_query_result(result)
+ check_zulip_realm_query_result(result)
+ check_lear_realm_query_result(result)
+
+ result = self.client_get("/activity/support", {"q": "Othello, the Moor of Venice"})
+ check_othello_user_query_result(result)
+ check_zulip_realm_query_result(result)
+
result = self.client_get("/activity/support", {"q": "lear, Hamlet <[email protected]>"})
check_hamlet_user_query_result(result)
check_zulip_realm_query_result(result)
diff --git a/analytics/views.py b/analytics/views.py
index 6770ce46573..a1187023576 100644
--- a/analytics/views.py
+++ b/analytics/views.py
@@ -1200,7 +1200,7 @@ def support(request: HttpRequest) -> HttpResponse:
if query:
key_words = get_invitee_emails_set(query)
- context["users"] = UserProfile.objects.filter(delivery_email__in=key_words)
+ users = set(UserProfile.objects.filter(delivery_email__in=key_words))
realms = set(Realm.objects.filter(string_id__in=key_words))
for key_word in key_words:
@@ -1217,7 +1217,7 @@ def support(request: HttpRequest) -> HttpResponse:
except Realm.DoesNotExist:
pass
except ValidationError:
- pass
+ users.update(UserProfile.objects.filter(full_name__iexact=key_word))
for realm in realms:
realm.customer = get_customer_by_realm(realm)
@@ -1233,6 +1233,10 @@ def support(request: HttpRequest) -> HttpResponse:
realm.current_plan.licenses = last_ledger_entry.licenses
realm.current_plan.licenses_used = get_latest_seat_count(realm)
+ # full_names can have , in them
+ users.update(UserProfile.objects.filter(full_name__iexact=query))
+
+ context["users"] = users
context["realms"] = realms
confirmations: List[Dict[str, Any]] = []
diff --git a/templates/analytics/support.html b/templates/analytics/support.html
index 4bd256c70bc..477080fb225 100644
--- a/templates/analytics/support.html
+++ b/templates/analytics/support.html
@@ -12,7 +12,7 @@
<br>
<form class="new-style">
<center>
- <input type="text" name="q" class="input-xxlarge search-query" placeholder="emails, string_ids, organization URLs separated by commas" value="{{ request.GET.get('q', '') }}" autofocus>
+ <input type="text" name="q" class="input-xxlarge search-query" placeholder="full names, emails, string_ids, organization URLs separated by commas" value="{{ request.GET.get('q', '') }}" autofocus>
<button type="submit" class="button small support-search-button">Search</button>
</center>
</form>