domain block and ban - bugfixes

This commit is contained in:
rimu 2024-02-02 16:58:30 +13:00
parent 888cce94fc
commit 57c13b1f7b
2 changed files with 18 additions and 6 deletions

View file

@ -23,13 +23,13 @@ def show_domain(domain_id):
if current_user.is_anonymous or current_user.ignore_bots:
posts = Post.query.join(Community, Community.id == Post.community_id).\
filter(Post.from_bot == False, Post.domain_id == domain.id, Community.banned == False).\
order_by(desc(Post.last_active)).all()
order_by(desc(Post.posted_at)).all()
else:
posts = Post.query.join(Community).filter(Post.domain_id == domain.id, Community.banned == False).order_by(desc(Post.last_active))
posts = Post.query.join(Community).filter(Post.domain_id == domain.id, Community.banned == False).order_by(desc(Post.posted_at))
# pagination
posts = posts.paginate(page=page, per_page=100, error_out=False)
next_url = url_for('main.index', page=posts.next_num) if posts.has_next else None
prev_url = url_for('main.index', page=posts.prev_num) if posts.has_prev and page != 1 else None
next_url = url_for('domain.show_domain', page=posts.next_num) if posts.has_next else None
prev_url = url_for('domain.show_domain', page=posts.prev_num) if posts.has_prev and page != 1 else None
return render_template('domain/domain.html', domain=domain, title=domain.name, posts=posts,
POST_TYPE_IMAGE=constants.POST_TYPE_IMAGE, POST_TYPE_LINK=constants.POST_TYPE_LINK,
next_url=next_url, prev_url=prev_url)
@ -48,8 +48,8 @@ def domains():
domains = domains.order_by(Domain.name)
domains = domains.paginate(page=page, per_page=100, error_out=False)
next_url = url_for('main.index', page=domains.next_num) if domains.has_next else None
prev_url = url_for('main.index', page=domains.prev_num) if domains.has_prev and page != 1 else None
next_url = url_for('domain.domains', page=domains.next_num) if domains.has_next else None
prev_url = url_for('domain.domains', page=domains.prev_num) if domains.has_prev and page != 1 else None
return render_template('domain/domains.html', title='All known domains', domains=domains,
next_url=next_url, prev_url=prev_url, search=search)

View file

@ -30,6 +30,18 @@
{% endfor %}
</tbody>
</table>
<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>
<aside class="col-12 col-md-4 side_pane" role="complementary">