diff --git a/app/domain/routes.py b/app/domain/routes.py index db00d930..54a74a38 100644 --- a/app/domain/routes.py +++ b/app/domain/routes.py @@ -62,10 +62,38 @@ def domains(): domains = domains.order_by(Domain.name) domains = domains.paginate(page=page, per_page=100, error_out=False) + ban_visibility_permission = False + + if not current_user.is_anonymous: + if not current_user.created_recently() and current_user.reputation > 100 or current_user.is_admin(): + ban_visibility_permission = True + 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, ban_visibility_permission=ban_visibility_permission) + + +@bp.route('/domains/banned', methods=['GET']) +@login_required +def blocked_domains(): + if not current_user.trustworthy(): + abort(404) + + page = request.args.get('page', 1, type=int) + search = request.args.get('search', '') + + domains = Domain.query.filter_by(banned=True) + if search != '': + domains = domains.filter(Domain.name.ilike(f'%{search}%')) + domains = domains.order_by(Domain.name) + domains = domains.paginate(page=page, per_page=100, error_out=False) + + 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_blocked.html', title='Domains blocked on this instance', domains=domains, next_url=next_url, prev_url=prev_url, search=search) diff --git a/app/models.py b/app/models.py index 8d4cc870..c42f8a59 100644 --- a/app/models.py +++ b/app/models.py @@ -591,6 +591,13 @@ class User(UserMixin, db.Model): return True return False + def trustworthy(self): + if self.is_admin(): + return True + if self.created_recently() or self.reputation < 100: + return False + return True + def link(self) -> str: if self.is_local(): return self.user_name @@ -1075,7 +1082,8 @@ class Filter(db.Model): def keywords_string(self): if self.keywords is None or self.keywords == '': return '' - return ', '.join(self.keywords.split('\n')) + split_keywords = [kw.strip() for kw in self.keywords.split('\n')] + return ', '.join(split_keywords) class Role(db.Model): diff --git a/app/static/structure.css b/app/static/structure.css index 4f3465ee..ca808a19 100644 --- a/app/static/structure.css +++ b/app/static/structure.css @@ -1288,4 +1288,15 @@ fieldset legend { max-width: 100%; } +@media (orientation: portrait) { + .flex-sm-fill.text-sm-center.nav-link.active{ + border-bottom: var(--bs-nav-tabs-border-width) solid var(--bs-border-color); + border-bottom-right-radius: var(--bs-nav-tabs-border-radius); + border-bottom-left-radius: var(--bs-nav-tabs-border-radius); + } + .card-header-tabs { + margin-bottom:8px; + } +} + /*# sourceMappingURL=structure.css.map */ diff --git a/app/templates/base.html b/app/templates/base.html index c2b5c857..92c8e266 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -167,10 +167,8 @@ diff --git a/app/templates/community/add_post.html b/app/templates/community/add_post.html index 70cbdd65..1f0a07c3 100644 --- a/app/templates/community/add_post.html +++ b/app/templates/community/add_post.html @@ -114,7 +114,7 @@