community search

This commit is contained in:
rimu 2024-02-02 15:57:22 +13:00
parent 2f3f8b6155
commit d4ea6aba0e
2 changed files with 6 additions and 3 deletions

View file

@ -155,15 +155,15 @@ def list_communities():
topic_id = int(request.args.get('topic_id', 0))
sort_by = text('community.' + request.args.get('sort_by') if request.args.get('sort_by') else 'community.post_reply_count desc')
topics = Topic.query.order_by(Topic.name).all()
communities = Community.query.filter_by(banned=False)
if search_param == '':
pass
else:
flash('Sorry, no search function yet. Use the topic filter for now.', 'warning')
# communities = Community.query.filter_by(banned=False)
communities = communities.filter(or_(Community.title.ilike(f"%{search_param}%"), Community.ap_id.ilike(f"%{search_param}%")))
#query = search(select(Community), search_param, sort=True) # todo: exclude banned communities from search
#communities = db.session.scalars(query).all()
communities = Community.query.filter_by(banned=False)
if topic_id != 0:
communities = communities.filter_by(topic_id=topic_id)

View file

@ -26,6 +26,9 @@
</form>
</span>
{% endif %}
<span class="mt-1 pl-4">
<form method="get"><input type="search" name="search" placeholder="{{ _('Search') }}" value="{{ search }}"></form>
</span>
</div>
</div>