support: Show realm owners in realm search results.

This commit is contained in:
Vishnu KS 2021-04-01 20:58:27 +05:30 committed by Tim Abbott
parent b2f6acc33f
commit 8139896e3d
3 changed files with 25 additions and 5 deletions

View File

@ -596,9 +596,11 @@ class TestSupportEndpoint(ZulipTestCase):
)
self.assert_in_success_response(
[
f"<b>Admins</b>: {self.example_email('desdemona')}, {self.example_email('iago')}\n",
'class="copy-button" data-copytext="{}, {}"'.format(
self.example_email("desdemona"), self.example_email("iago")
f"<b>Admins</b>: {self.example_email('iago')}\n",
f"<b>Owners</b>: {self.example_email('desdemona')}\n",
'class="copy-button" data-copytext="{}">'.format(self.example_email("iago")),
'class="copy-button" data-copytext="{}">'.format(
self.example_email("desdemona")
),
],
result,

View File

@ -1429,13 +1429,21 @@ def support(request: HttpRequest) -> HttpResponse:
context["confirmations"] = confirmations
def get_realm_admin_emails_as_string(realm: Realm) -> str:
def get_realm_owner_emails_as_string(realm: Realm) -> str:
return ", ".join(
realm.get_human_admin_users()
realm.get_human_owner_users()
.order_by("delivery_email")
.values_list("delivery_email", flat=True)
)
def get_realm_admin_emails_as_string(realm: Realm) -> str:
return ", ".join(
realm.get_human_admin_users(include_realm_owners=False)
.order_by("delivery_email")
.values_list("delivery_email", flat=True)
)
context["get_realm_owner_emails_as_string"] = get_realm_owner_emails_as_string
context["get_realm_admin_emails_as_string"] = get_realm_admin_emails_as_string
context["get_discount_for_realm"] = get_discount_for_realm
context["realm_icon_url"] = realm_icon_url

View File

@ -4,11 +4,21 @@
<a target="_blank" rel="noopener noreferrer" href="/stats/realm/{{ realm.string_id }}/">stats</a> |
<a target="_blank" rel="noopener noreferrer" href="/realm_activity/{{ realm.string_id }}/">activity</a><br>
<b>Date created</b>: {{ realm.date_created|timesince }} ago<br>
{% set owner_emails_string = get_realm_owner_emails_as_string(realm) %}
<b>Owners</b>: {{ owner_emails_string }}
{% if owner_emails_string %}
<a title="Copy emails" class="copy-button" data-copytext="{{ owner_emails_string }}">
<i class="fa fa-copy"></i>
</a>
{% endif %}
<br>
{% set admin_emails_string = get_realm_admin_emails_as_string(realm) %}
<b>Admins</b>: {{ admin_emails_string }}
{% if admin_emails_string %}
<a title="Copy emails" class="copy-button" data-copytext="{{ admin_emails_string }}">
<i class="fa fa-copy"></i>
</a>
{% endif %}
<form method="POST">
<b>Status</b>:<br>
{{ csrf_input }}