redesign domains; add banned domains; add permission control

This commit is contained in:
rra 2024-03-10 20:17:53 +01:00
parent 0aee1cf6df
commit b9f3e92acf
2 changed files with 106 additions and 35 deletions

View file

@ -6,67 +6,60 @@
{% from 'bootstrap/form.html' import render_form %} {% from 'bootstrap/form.html' import render_form %}
{% block app_content %} {% block app_content %}
<div class="card col-md-8" style="max-width:unset;">
<div class="row"> <div class="card-header">
<div class="col-12 col-md-8 position-relative main_pane"> <nav class="mb-2" aria-label="breadcrumb" id="breadcrumb_nav" title="Navigation">
<nav aria-label="breadcrumb" id="breadcrumb_nav" title="Navigation">
<ol class="breadcrumb"> <ol class="breadcrumb">
<li class="breadcrumb-item"><a href="/">{{ _('Home') }}</a></li> <li class="breadcrumb-item"><a href="/">{{ _('Home') }}</a></li>
<li class="breadcrumb-item active">Domains</li> <li class="breadcrumb-item active">Domains</li>
</ol> </ol>
</nav> </nav>
<ul class="nav nav-tabs flex-column flex-sm-row card-header-tabs">
<div class="btn-group mt-1 mb-2"> <li class="nav-item">
<a href="#" class="btn {{ 'btn-primary' if sort == 'hot' else 'btn-outline-secondary' }}" rel="nofollow noindex"> <a class="flex-sm-fill text-sm-center nav-link active" href="/domains">All Domains</a>
{{ _('Banned') }} </li>
</a> {% if not current_user.is_anonymous %}
<a href="#" class="btn {{ 'btn-primary' if sort == 'top' else 'btn-outline-secondary' }}" rel="nofollow noindex"> <li class="nav-item">
{{ _('Allowed') }} {% if not ban_visibility_permission %}
</a> <span title="{{ _('Your account is either too new or too low reputation to be able to see banned domains') }}">
<a href="#" class="btn {{ 'btn-primary' if sort == 'new' else 'btn-outline-secondary' }}" rel="nofollow noindex"> <a class="flex-sm-fill text-sm-center nav-link disabled" href="/domains/banned">Banned Domains</a></span>{% else %}
{{ _('Blocked') }} <a class="flex-sm-fill text-sm-center nav-link" href="/domains/banned">Banned Domains</a>
</a> {% endif %}
<a href="#" class="btn {{ 'btn-primary' if sort == 'active' else 'btn-outline-secondary' }}" rel="nofollow noindex"> </li>
{{ _('Active') }} {% endif %}
</a> </ul>
</div> </div>
<div class="card-body">
<h1 class="">{{ _('Domains') }}</h1>
{% if search == '' %} {% if search == '' %}
<h1 class="mt-2">{{ _('All known domains') }}</h1> <p class="card-text">All domains this instance knows about</p>
{% else %} {% else %}
<h1 class="mt-2">{{ _('Domains containing %(search)s', search=search) }}</h1> <p class="card-text">Domains containing "{{ _('%(search)s', search=search) }}"</p>
{% endif %} {% endif %}
<form method="get"><input type="search" name="search" value="{{ search }}" placeholder="{{ _('Search') }}" autofocus></form> <form method="get"><input type="search" name="search" value="{{ search }}" placeholder="{{ _('Search') }}" autofocus></form>
<div class="table-responsive-sm">
<table class="table table-striped"> <table class="table table-striped">
<tr> <tr>
<th>Domain</th> <th>Domain</th>
<th><span title="{{ _('How many times has something on this domain been posted?') }}"># Posts</span></th> <th><span title="{{ _('How many times has something on this domain been posted?') }}"># Posts</span></th>
<th><span title="{{ _('Has the domain been banned or allowed?') }}">Status</span></th> {% if not current_user.is_anonymous %}{% if user_access('ban users', current_user.id) or user_access('manage users', current_user.id) %}<th>Actions</th>{%endif%}{%endif%}
<th>Actions</th>
</tr> </tr>
{% for domain in domains %} {% for domain in domains %}
<tr> <tr>
<td><a href="{{ url_for('domain.show_domain', domain_id=domain.id) }}">{{ domain.name }}</a></td> <td><a href="{{ url_for('domain.show_domain', domain_id=domain.id) }}">{{ domain.name }}</a></td>
<td>{{ domain.post_count }}</td> <td>{{ domain.post_count }}</td>
<th>{{ 'Banned'|safe if domain.banned else 'Allowed'|safe }}</th>
<td> <td>
{% if domain.blocked_by(current_user) %} {% if not current_user.is_anonymous %}
<a href="/d/{{ domain.id }}/unblock" title="{{ _('Unblocking the domain allows you to see posts with that domain again') }}">{{ _('Unblock') }}</a>
{% else %}
<a href="/d/{{ domain.id }}/block" title="{{ _('Blocking the domain means you wont see posts that reference it') }}">{{ _('Block') }}</a>
{% endif %}
{% if user_access('ban users', current_user.id) or user_access('manage users', current_user.id) %} {% if user_access('ban users', current_user.id) or user_access('manage users', current_user.id) %}
{% if domain.banned %} <a class="confirm_first btn btn-primary" title="{{ _('Banning this domain will delete all posts linking to this domain and prevent future posts linking to that domain.') }}" href="/d/{{ domain.id }}/ban">{{ _('Ban') }}</a>
<a class="confirm_first" title="{{ _('Unbanning this domain allows future posts linking to that domain.') }}" href="/d/{{ domain.id }}/unban">{{ _('Unban') }}</a> {% endif %}
{% else %}
<a class="confirm_first" title="{{ _('Banning this domain will delete all posts linking to this domain and prevent future posts linking to that domain.') }}" href="/d/{{ domain.id }}/ban">{{ _('Ban') }}</a>
{% endif %}
{% endif %} {% endif %}
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>
</div>
<nav aria-label="Pagination" class="mt-4" role="navigation"> <nav aria-label="Pagination" class="mt-4" role="navigation">
{% if prev_url %} {% if prev_url %}
<a href="{{ prev_url }}" class="btn btn-primary" rel="nofollow"> <a href="{{ prev_url }}" class="btn btn-primary" rel="nofollow">
@ -79,6 +72,7 @@
</a> </a>
{% endif %} {% endif %}
</nav> </nav>
</div>
</div> </div>
</div> </div>
{% endblock %} {% endblock %}

View file

@ -0,0 +1,77 @@
{% if theme() and file_exists('app/templates/themes/' + theme() + '/base.html') %}
{% extends 'themes/' + theme() + '/base.html' %}
{% else %}
{% extends "base.html" %}
{% endif %} %}
{% from 'bootstrap/form.html' import render_form %}
{% block app_content %}
<div class="card col-md-8" style="max-width:unset;">
<div class="card-header">
<nav class="mb-2" aria-label="breadcrumb" id="breadcrumb_nav" title="Navigation">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="/">{{ _('Home') }}</a></li>
<li class="breadcrumb-item active">Domains</li>
</ol>
</nav>
<ul class="nav nav-tabs flex-column flex-sm-row card-header-tabs">
<li class="nav-item">
<a class="flex-sm-fill text-sm-center nav-link" href="/domains">All Domains</a>
</li>
<li class="nav-item">
<a class="flex-sm-fill text-sm-center nav-link active" href="/domains/banned">Banned Domains</a>
</li>
</ul>
</div>
<div class="card-body">
<h1 class="">{{ _('Domains') }}</h1>
{% if not ban_visibility_permission %}
<p class="card-text">Your account is either too new or too low reputation to be able to see banned domains on this instance-</p>
{% else %}
{% if search == '' %}
<p class="card-text">All domains this instance banned</p>
{% else %}
<p class="card-text">Banned domains containing "{{ _('%(search)s', search=search) }}"</p>
{% endif %}
<form method="get"><input type="search" name="search" value="{{ search }}" placeholder="{{ _('Search') }}" autofocus></form>
<div class="table-responsive-sm">
<table class="table table-striped">
<tr>
<th>Domain</th>
{% if user_access('ban users', current_user.id) or user_access('manage users', current_user.id) %}<th>Actions</th>{%endif%}
</tr>
{% for domain in domains %}
<tr>
<td><a href="{{ url_for('domain.show_domain', domain_id=domain.id) }}">{{ domain.name }}</a></td>
<td>
{% if user_access('ban users', current_user.id) or user_access('manage users', current_user.id) %}
{% if domain.banned %}
<a class="btn btn-primary confirm_first" title="{{ _('Unbanning this domain allows future posts linking to that domain.') }}" href="/d/{{ domain.id }}/unban">{{ _('Unban') }}</a>
{% else %}
<a class="btn btn-primary confirm_first" title="{{ _('Banning this domain will delete all posts linking to this domain and prevent future posts linking to that domain.') }}" href="/d/{{ domain.id }}/ban">{{ _('Ban') }}</a>
{% endif %}
{% endif %}
</td>
</tr>
{% endfor %}
</table>
</div>
<nav aria-label="Pagination" class="mt-4" role="navigation">
{% if prev_url %}
<a href="{{ prev_url }}" class="btn btn-primary" rel="nofollow">
<span aria-hidden="true">&larr;</span> {{ _('Previous page') }}
</a>
{% endif %}
{% if next_url %}
<a href="{{ next_url }}" class="btn btn-primary" rel="nofollow">
{{ _('Next page') }} <span aria-hidden="true">&rarr;</span>
</a>
{% endif %}
</nav>
</div>
{% endif %}
</div>
</div>
{% endblock %}