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 @@
{{ _('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/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 @@
{{ _('You have unsubscribed from emails about unread notifications. We might email you for other reasons, though.') }}
- +{{ _('You have unsubscribed from the email newsletter. We might email you for other reasons, though.') }}
- +