Merge pull request 'Rework columns in admin views of users and communities' (#359) from h3ndrik/pyfedi:adminviews into main

Reviewed-on: https://codeberg.org/rimu/pyfedi/pulls/359
This commit is contained in:
rimu 2024-11-26 19:32:44 +00:00
commit 9924306fbe
4 changed files with 12 additions and 31 deletions

View file

@ -19,7 +19,6 @@
<table class="table table-striped"> <table class="table table-striped">
<tr> <tr>
<th>Name</th> <th>Name</th>
<th>Title</th>
<th>Topic</th> <th>Topic</th>
<th>#&nbsp;Posts</th> <th>#&nbsp;Posts</th>
<th>Retention</th> <th>Retention</th>
@ -32,8 +31,8 @@
</tr> </tr>
{% for community in communities.items %} {% for community in communities.items %}
<tr> <tr>
<td><a href="/c/{{ community.link() }}">{{ community.name }}</a></td> <td>{{ render_communityname(community, add_domain=False) }}{% if community.banned %} (banned){% endif %}<br />
<td>{{ render_communityname(community) }}{% if community.banned %} (banned){% endif %}</td> !<a href="/c/{{ community.link() }}">{{ community.name }}</a><wbr />@<a href="{{ community.ap_profile_id }}">{{ community.ap_domain }}</a></td>
<td>{{ community.topic.name }}</td> <td>{{ community.topic.name }}</td>
<td>{{ community.post_count }}</td> <td>{{ community.post_count }}</td>
<td>{{ community.content_retention if community.content_retention != -1 }}</td> <td>{{ community.content_retention if community.content_retention != -1 }}</td>

View file

@ -20,7 +20,6 @@
<table class="table table-striped mt-1"> <table class="table table-striped mt-1">
<tr> <tr>
<th title="{{ _('Display name.') }}">{{ _('Name') }}</th> <th title="{{ _('Display name.') }}">{{ _('Name') }}</th>
<th>{{ _('Local/Remote') }}</th>
<th title="{{ _('Last seen.') }}">{{ _('Seen') }}</th> <th title="{{ _('Last seen.') }}">{{ _('Seen') }}</th>
<th title="{{ _('Attitude: Percentage of up votes vs. down votes the account made.') }}">{{ _('Attitude') }}</th> <th title="{{ _('Attitude: Percentage of up votes vs. down votes the account made.') }}">{{ _('Attitude') }}</th>
<th title="{{ _('Reputation: The Karma of the account. Total up votes minus down votes they got.') }}">{{ _('Reputation') }}</th> <th title="{{ _('Reputation: The Karma of the account. Total up votes minus down votes they got.') }}">{{ _('Reputation') }}</th>
@ -32,10 +31,8 @@
</tr> </tr>
{% for user in users.items %} {% for user in users.items %}
<tr> <tr>
<td><a href="/u/{{ user.link() }}"> <td>{{ render_username(user, add_domain=False) }}<br />
<img src="{{ user.avatar_thumbnail() }}" class="community_icon rounded-circle" loading="lazy" /> <a href="/u/{{ user.link() }}">{{ user.user_name }}</a>{% if not user.is_local() %}<wbr />@<a href="{{ user.ap_profile_id }}">{{ user.ap_domain }}</a>{% endif %}</td>
{{ user.display_name() }}</a></td>
<td>{% if user.is_local() %}Local{% else %}<a href="{{ user.ap_profile_id }}">Remote</a>{% endif %}</td>
<td>{% if request.args.get('local_remote', '') == 'local' %} <td>{% if request.args.get('local_remote', '') == 'local' %}
{{ arrow.get(user.last_seen).humanize(locale=locale) }} {{ arrow.get(user.last_seen).humanize(locale=locale) }}
{% else %} {% else %}
@ -48,13 +45,7 @@
<td>{{ user.reports if user.reports > 0 }} </td> <td>{{ user.reports if user.reports > 0 }} </td>
<td>{{ user.ip_address if user.ip_address }}<br />{{ user.ip_address_country if user.ip_address_country }}</td> <td>{{ user.ip_address if user.ip_address }}<br />{{ user.ip_address_country if user.ip_address_country }}</td>
<td>{{ user.referrer if user.referrer }} </td> <td>{{ user.referrer if user.referrer }} </td>
<td><a href="/u/{{ user.link() }}">View local</a> | <td><a href="{{ url_for('admin.admin_user_edit', user_id=user.id) }}">Edit</a> |
{% if not user.is_local() %}
<a href="{{ user.ap_profile_id }}">View remote</a> |
{% else %}
View remote |
{% endif %}
<a href="{{ url_for('admin.admin_user_edit', user_id=user.id) }}">Edit</a> |
<a href="{{ url_for('admin.admin_user_delete', user_id=user.id) }}" class="confirm_first">Delete</a> <a href="{{ url_for('admin.admin_user_delete', user_id=user.id) }}" class="confirm_first">Delete</a>
</td> </td>
</tr> </tr>

View file

@ -22,7 +22,6 @@
<table class="table table-striped mt-1"> <table class="table table-striped mt-1">
<tr> <tr>
<th>Name</th> <th>Name</th>
<th>Local/Remote</th>
<th>Seen</th> <th>Seen</th>
<th>Attitude</th> <th>Attitude</th>
<th>Rep</th> <th>Rep</th>
@ -34,10 +33,8 @@
</tr> </tr>
{% for user in users.items %} {% for user in users.items %}
<tr> <tr>
<td><a href="/u/{{ user.link() }}"> <td>{{ render_username(user, add_domain=False) }}<br />
<img src="{{ user.avatar_thumbnail() }}" class="community_icon rounded-circle" loading="lazy" /> <a href="/u/{{ user.link() }}">{{ user.user_name }}</a>{% if not user.is_local() %}<wbr />@<a href="{{ user.ap_profile_id }}">{{ user.ap_domain }}</a>{% endif %}</td>
{{ user.display_name() }}</a></td>
<td>{% if user.is_local() %}Local{% else %}<a href="{{ user.ap_profile_id }}">Remote</a>{% endif %}</td>
<td>{% if request.args.get('local_remote', '') == 'local' %} <td>{% if request.args.get('local_remote', '') == 'local' %}
{{ arrow.get(user.last_seen).humanize(locale=locale) }} {{ arrow.get(user.last_seen).humanize(locale=locale) }}
{% else %} {% else %}
@ -50,13 +47,7 @@
<td>{{ user.reports if user.reports > 0 }} </td> <td>{{ user.reports if user.reports > 0 }} </td>
<td>{{ user.ip_address if user.ip_address }} </td> <td>{{ user.ip_address if user.ip_address }} </td>
<td>{{ user.referrer if user.referrer }} </td> <td>{{ user.referrer if user.referrer }} </td>
<td><a href="/u/{{ user.link() }}">View local</a> | <td><a href="{{ url_for('admin.admin_user_edit', user_id=user.id) }}">Edit</a> |
{% if not user.is_local() %}
<a href="{{ user.ap_profile_id }}">View remote</a> |
{% else %}
View remote |
{% endif %}
<a href="{{ url_for('admin.admin_user_edit', user_id=user.id) }}">Edit</a> |
<a href="{{ url_for('admin.admin_user_delete', user_id=user.id) }}" class="confirm_first">Delete</a> <a href="{{ url_for('admin.admin_user_delete', user_id=user.id) }}" class="confirm_first">Delete</a>
</td> </td>
</tr> </tr>

View file

@ -1,4 +1,4 @@
{% macro render_username(user) -%} {% macro render_username(user, add_domain=True) -%}
<span class="render_username"> <span class="render_username">
{% if user.deleted -%} {% if user.deleted -%}
[deleted] [deleted]
@ -7,7 +7,7 @@
{% if user.avatar_id and not low_bandwidth and not collapsed -%} {% if user.avatar_id and not low_bandwidth and not collapsed -%}
<img src="{{ user.avatar_thumbnail() }}" alt="" loading="lazy" /> <img src="{{ user.avatar_thumbnail() }}" alt="" loading="lazy" />
{% endif -%} {% endif -%}
{{ user.display_name() }}{% if not user.is_local() %}<span class="text-muted">@{{ user.ap_domain }}</span>{% endif %} {{ user.display_name() }}{% if add_domain and not user.is_local() %}<span class="text-muted">@{{ user.ap_domain }}</span>{% endif %}
</a> </a>
{% if user.created_recently() -%} {% if user.created_recently() -%}
<span class="fe fe-new-account" title="New account"> </span> <span class="fe fe-new-account" title="New account"> </span>
@ -26,13 +26,13 @@
{% endif -%} {% endif -%}
</span> </span>
{% endmacro -%} {% endmacro -%}
{% macro render_communityname(community) -%} {% macro render_communityname(community, add_domain=True) -%}
<span class="render_community"> <span class="render_community">
<a href="/c/{{ community.link() }}" aria-label="{{ _('Go to community %(name)s', name=community.name) }}"> <a href="/c/{{ community.link() }}" aria-label="{{ _('Go to community %(name)s', name=community.name) }}">
{% if community.icon_id and not low_bandwidth and not collapsed -%} {% if community.icon_id and not low_bandwidth and not collapsed -%}
<img src="{{ community.icon_image('tiny') }}" class="community_icon rounded-circle" alt="" loading="lazy" /> <img src="{{ community.icon_image('tiny') }}" class="community_icon rounded-circle" alt="" loading="lazy" />
{% endif -%} {% endif -%}
c/{{ community.display_name() }} {{ community.title }}{% if add_domain and not community.is_local() %}<span class="text-muted">@{{ community.ap_domain }}</span>{% endif %}
</a> </a>
</span> </span>
{% endmacro -%} {% endmacro -%}