diff --git a/app/querybuilder.py b/app/querybuilder.py index 9406406..a7f1323 100644 --- a/app/querybuilder.py +++ b/app/querybuilder.py @@ -28,13 +28,16 @@ class QueryBuilder: self.order_by = args.get("sort") or "score" self.order_dir = args.get("order") or "desc" + if self.search is not None and self.search.strip() == "": + self.search = None + def buildPackageQuery(self): query = Package.query.filter_by(soft_deleted=False, approved=True) if len(self.types) > 0: query = query.filter(Package.type.in_(self.types)) - if self.search is not None and self.search.strip() != "": + if self.search: query = query.filter(Package.title.ilike('%' + self.search + '%')) if self.random: @@ -69,17 +72,14 @@ class QueryBuilder: def buildTopicQuery(self): topics = ForumTopic.query \ .filter(~ db.exists().where(Package.forums==ForumTopic.topic_id)) \ - .order_by(db.asc(ForumTopic.wip), db.asc(ForumTopic.name), db.asc(ForumTopic.title)) \ - .filter(ForumTopic.title.ilike('%' + self.search + '%')) + .order_by(db.asc(ForumTopic.wip), db.asc(ForumTopic.name), db.asc(ForumTopic.title)) + + if self.search: + topics = topics.filter(ForumTopic.title.ilike('%' + self.search + '%')) if len(self.types) > 0: topics = topics.filter(ForumTopic.type.in_(self.types)) - if self.hide_nonfree: - topics = topics \ - .filter(Package.license.has(License.is_foss == True)) \ - .filter(Package.media_license.has(License.is_foss == True)) - if self.limit: topics = topics.limit(self.limit) diff --git a/app/views/__init__.py b/app/views/__init__.py index 7ca7620..303ed2a 100644 --- a/app/views/__init__.py +++ b/app/views/__init__.py @@ -56,9 +56,8 @@ def home_page(): return render_template("index.html", count=count, \ new=new, pop_mod=pop_mod, pop_txp=pop_txp, pop_gam=pop_gam) -from . import users, githublogin, packages, meta, threads, api -from . import tasks, admin, notifications, tagseditor, licenseseditor -from . import sass, thumbnails +from . import users, packages, meta, threads, api +from . import sass, thumbnails, tasks, admin @menu.register_menu(app, ".help", "Help", order=19, endpoint_arguments_constructor=lambda: { 'path': 'help' }) @app.route('//') diff --git a/app/views/admin/__init__.py b/app/views/admin/__init__.py new file mode 100644 index 0000000..b4b4f99 --- /dev/null +++ b/app/views/admin/__init__.py @@ -0,0 +1,18 @@ +# Content DB +# Copyright (C) 2018 rubenwardy +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +from . import admin, licenseseditor, tagseditor, todo diff --git a/app/views/admin.py b/app/views/admin/admin.py similarity index 100% rename from app/views/admin.py rename to app/views/admin/admin.py diff --git a/app/views/licenseseditor.py b/app/views/admin/licenseseditor.py similarity index 100% rename from app/views/licenseseditor.py rename to app/views/admin/licenseseditor.py diff --git a/app/views/tagseditor.py b/app/views/admin/tagseditor.py similarity index 100% rename from app/views/tagseditor.py rename to app/views/admin/tagseditor.py diff --git a/app/views/packages/todo.py b/app/views/admin/todo.py similarity index 100% rename from app/views/packages/todo.py rename to app/views/admin/todo.py diff --git a/app/views/packages/__init__.py b/app/views/packages/__init__.py index 8bb6c1a..5df5376 100644 --- a/app/views/packages/__init__.py +++ b/app/views/packages/__init__.py @@ -15,4 +15,4 @@ # along with this program. If not, see . -from . import packages, todo, screenshots, releases +from . import packages, screenshots, releases diff --git a/app/views/users/__init__.py b/app/views/users/__init__.py new file mode 100644 index 0000000..45af431 --- /dev/null +++ b/app/views/users/__init__.py @@ -0,0 +1,18 @@ +# Content DB +# Copyright (C) 2018 rubenwardy +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +from . import users, githublogin, notifications diff --git a/app/views/githublogin.py b/app/views/users/githublogin.py similarity index 100% rename from app/views/githublogin.py rename to app/views/users/githublogin.py diff --git a/app/views/notifications.py b/app/views/users/notifications.py similarity index 100% rename from app/views/notifications.py rename to app/views/users/notifications.py diff --git a/app/views/users.py b/app/views/users/users.py similarity index 100% rename from app/views/users.py rename to app/views/users/users.py