diff --git a/app/main/routes.py b/app/main/routes.py index 2eb33eb9..864a7bd4 100644 --- a/app/main/routes.py +++ b/app/main/routes.py @@ -326,9 +326,26 @@ def list_subscribed_communities(): def list_instances(): page = request.args.get('page', 1, type=int) search = request.args.get('search', '') + filter = request.args.get('filter', '') low_bandwidth = request.cookies.get('low_bandwidth', '0') == '1' instances = Instance.query.order_by(Instance.domain) + if search: + instances = instances.filter(Instance.domain.ilike(f"%{search}%")) + title = _('Instances') + if filter: + if filter == 'trusted': + instances = instances.filter(Instance.trusted == True) + title = _('Trusted instances') + elif filter == 'online': + instances = instances.filter(Instance.dormant == False, Instance.gone_forever == False) + title = _('Online instances') + elif filter == 'dormant': + instances = instances.filter(Instance.dormant == True, Instance.gone_forever == False) + title = _('Dormant instances') + elif filter == 'gone_forever': + instances = instances.filter(Instance.gone_forever == True) + title = _('Gone forever instances') # Pagination instances = instances.paginate(page=page, @@ -338,7 +355,7 @@ def list_instances(): prev_url = url_for('main.list_instances', page=instances.prev_num) if instances.has_prev and page != 1 else None return render_template('list_instances.html', instances=instances, - title=_('Instances'), search=search, + title=title, search=search, filter=filter, next_url=next_url, prev_url=prev_url, low_bandwidth=low_bandwidth, moderating_communities=moderating_communities(current_user.get_id()), diff --git a/app/models.py b/app/models.py index 3e984366..0ed3fbee 100644 --- a/app/models.py +++ b/app/models.py @@ -82,6 +82,8 @@ class Instance(db.Model): return role and role.role == 'admin' def votes_are_public(self): + if self.trusted is True: # only vote privately with untrusted instances + return False return self.software.lower() == 'lemmy' or self.software.lower() == 'mbin' or self.software.lower() == 'kbin' def post_count(self): diff --git a/app/templates/list_instances.html b/app/templates/list_instances.html index 42c0fc2d..99a24752 100644 --- a/app/templates/list_instances.html +++ b/app/templates/list_instances.html @@ -9,43 +9,63 @@
{% if search == '' %} -

{{ _('Instances') }}

+

{{ title }}

{% else %} -

{{ _('Instances containing "%(search)s"', search=search) }}

+

{{ title }}

{% endif %} +
+ +
+ {{ _('Online') }} | + {{ _('Dormant') }} | + {{ _('Gone forever') }} | + {{ _('Trusted') }} -
- - - - - - - - - {% for instance in instances %} - - - - - - - - {% endfor %} -
{{ _('Instance') }}{{ _('Software') }}{{ _('Version') }}{{ _('Heard from') }}{{ _('Sent to') }}
{{ instance.domain }}{{ instance.software }}{{ instance.version if instance.version }}{{ arrow.get(instance.last_seen).humanize(locale=locale) if instance.last_seen }}{{ arrow.get(instance.last_successful_send).humanize(locale=locale) if instance.last_successful_send }}
-
-
diff --git a/app/templates/user/edit_settings.html b/app/templates/user/edit_settings.html index 4c6ea85f..b834d7b3 100644 --- a/app/templates/user/edit_settings.html +++ b/app/templates/user/edit_settings.html @@ -34,6 +34,7 @@ {{ render_field(form.default_filter) }} {{ render_field(form.theme) }} {{ render_field(form.vote_privately) }} + {{ _('Votes will be sent to untrusted instances using an alt') }} {{ render_field(form.submit) }}

diff --git a/app/templates/user/email_notifs_unsubscribed.html b/app/templates/user/email_notifs_unsubscribed.html index b8b02885..c3a4db0f 100644 --- a/app/templates/user/email_notifs_unsubscribed.html +++ b/app/templates/user/email_notifs_unsubscribed.html @@ -8,7 +8,7 @@

{{ _('Unsubscribed') }}

{{ _('You have unsubscribed from emails about unread notifications. We might email you for other reasons, though.') }}

-

{{ _('More email settings') }}

+

{{ _('More email settings') }}

diff --git a/app/templates/user/newsletter_unsubscribed.html b/app/templates/user/newsletter_unsubscribed.html index 4f8dc26a..6e002fca 100644 --- a/app/templates/user/newsletter_unsubscribed.html +++ b/app/templates/user/newsletter_unsubscribed.html @@ -8,7 +8,7 @@
{{ _('Unsubscribed') }}

{{ _('You have unsubscribed from the email newsletter. We might email you for other reasons, though.') }}

-

{{ _('More email settings') }}

+

{{ _('More email settings') }}

diff --git a/app/user/routes.py b/app/user/routes.py index 6d40d3cf..eda69a5d 100644 --- a/app/user/routes.py +++ b/app/user/routes.py @@ -360,7 +360,7 @@ def export_user_settings(user): @bp.route('/user/settings', methods=['GET', 'POST']) @login_required -def change_settings(): +def user_settings(): user = User.query.filter_by(id=current_user.id, deleted=False, banned=False, ap_id=None).first() if user is None: abort(404)