mirror of https://github.com/zulip/zulip.git
activity: Add header area to user activity view.
This commit is contained in:
parent
d54ca85de2
commit
d1e7c082b3
|
@ -55,7 +55,7 @@ def make_table(
|
|||
*,
|
||||
header: list[ActivityHeaderEntry] | None = None,
|
||||
totals: Any | None = None,
|
||||
stats_link: Markup | None = None,
|
||||
title_link: Markup | None = None,
|
||||
has_row_class: bool = False,
|
||||
) -> str:
|
||||
if not has_row_class:
|
||||
|
@ -66,7 +66,7 @@ def make_table(
|
|||
rows = list(map(fix_row, rows))
|
||||
|
||||
data = dict(
|
||||
title=title, cols=cols, rows=rows, header=header, totals=totals, stats_link=stats_link
|
||||
title=title, cols=cols, rows=rows, header=header, totals=totals, title_link=title_link
|
||||
)
|
||||
|
||||
content = loader.render_to_string(
|
||||
|
@ -142,6 +142,13 @@ def realm_stats_link(realm_str: str) -> Markup:
|
|||
return Markup('<a href="{url}"><i class="fa fa-pie-chart"></i></a>').format(url=url)
|
||||
|
||||
|
||||
def user_support_link(email: str) -> Markup:
|
||||
support_url = reverse("support")
|
||||
query = urlencode({"q": email})
|
||||
url = append_url_query_string(support_url, query)
|
||||
return Markup('<a href="{url}"><i class="fa fa-gear"></i></a>').format(url=url)
|
||||
|
||||
|
||||
def realm_support_link(realm_str: str) -> Markup:
|
||||
support_url = reverse("support")
|
||||
query = urlencode({"q": realm_str})
|
||||
|
|
|
@ -146,7 +146,7 @@ def realm_user_summary_table(
|
|||
return row["cells"][4]
|
||||
|
||||
rows = sorted(rows, key=by_last_heard_from, reverse=True)
|
||||
content = make_table(title, cols, rows, stats_link=stats_link, has_row_class=True)
|
||||
content = make_table(title, cols, rows, title_link=stats_link, has_row_class=True)
|
||||
return content
|
||||
|
||||
|
||||
|
|
|
@ -4,7 +4,12 @@ from django.db.models import QuerySet
|
|||
from django.http import HttpRequest, HttpResponse
|
||||
from django.shortcuts import render
|
||||
|
||||
from corporate.lib.activity import format_optional_datetime, make_table
|
||||
from corporate.lib.activity import (
|
||||
ActivityHeaderEntry,
|
||||
format_optional_datetime,
|
||||
make_table,
|
||||
user_support_link,
|
||||
)
|
||||
from zerver.decorator import require_server_admin
|
||||
from zerver.models import UserActivity, UserProfile
|
||||
from zerver.models.users import get_user_profile_by_id
|
||||
|
@ -36,6 +41,7 @@ def get_user_activity(request: HttpRequest, user_profile_id: int) -> HttpRespons
|
|||
user_profile = get_user_profile_by_id(user_profile_id)
|
||||
records = get_user_activity_records(user_profile)
|
||||
|
||||
title = f"{user_profile.full_name}"
|
||||
cols = [
|
||||
"Query",
|
||||
"Client",
|
||||
|
@ -52,8 +58,14 @@ def get_user_activity(request: HttpRequest, user_profile_id: int) -> HttpRespons
|
|||
]
|
||||
|
||||
rows = list(map(row, records))
|
||||
title = f"{user_profile.delivery_email} ({user_profile.realm.name})"
|
||||
content = make_table(title, cols, rows)
|
||||
|
||||
header_entries = []
|
||||
header_entries.append(ActivityHeaderEntry(name="Email", value=user_profile.delivery_email))
|
||||
header_entries.append(ActivityHeaderEntry(name="Realm", value=user_profile.realm.name))
|
||||
|
||||
user_support = user_support_link(user_profile.delivery_email)
|
||||
|
||||
content = make_table(title, cols, rows, header=header_entries, title_link=user_support)
|
||||
|
||||
return render(
|
||||
request,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<h3>{{ data.title }} {% if data.stats_link %}{{ data.stats_link }}{% endif %}</h3>
|
||||
<h3>{{ data.title }} {% if data.title_link %}{{ data.title_link }}{% endif %}</h3>
|
||||
|
||||
{% if data.title == "Remote servers" %}
|
||||
{% include "corporate/activity/remote_activity_key.html" %}
|
||||
|
|
Loading…
Reference in New Issue