aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorrubenwardy <rw@rubenwardy.com>2019-01-08 17:37:33 +0000
committerrubenwardy <rw@rubenwardy.com>2019-01-08 17:37:33 +0000
commit9639cf04f1b54865884850d608f08b5df4afe169 (patch)
tree871a03bc37826a760f44e60c50b68fac880c4eee /app
parent9866e43b4b4c7ff5c2338e1ed681661496800db7 (diff)
downloadcheatdb-9639cf04f1b54865884850d608f08b5df4afe169.tar.xz
Improve views subfoldering
Diffstat (limited to 'app')
-rw-r--r--app/querybuilder.py16
-rw-r--r--app/views/__init__.py5
-rw-r--r--app/views/admin/__init__.py18
-rw-r--r--app/views/admin/admin.py (renamed from app/views/admin.py)0
-rw-r--r--app/views/admin/licenseseditor.py (renamed from app/views/licenseseditor.py)0
-rw-r--r--app/views/admin/tagseditor.py (renamed from app/views/tagseditor.py)0
-rw-r--r--app/views/admin/todo.py (renamed from app/views/packages/todo.py)0
-rw-r--r--app/views/packages/__init__.py2
-rw-r--r--app/views/users/__init__.py18
-rw-r--r--app/views/users/githublogin.py (renamed from app/views/githublogin.py)0
-rw-r--r--app/views/users/notifications.py (renamed from app/views/notifications.py)0
-rw-r--r--app/views/users/users.py (renamed from app/views/users.py)0
12 files changed, 47 insertions, 12 deletions
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('/<path:path>/')
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 <https://www.gnu.org/licenses/>.
+
+
+from . import admin, licenseseditor, tagseditor, todo
diff --git a/app/views/admin.py b/app/views/admin/admin.py
index b2b615d..b2b615d 100644
--- a/app/views/admin.py
+++ b/app/views/admin/admin.py
diff --git a/app/views/licenseseditor.py b/app/views/admin/licenseseditor.py
index 343f4ee..343f4ee 100644
--- a/app/views/licenseseditor.py
+++ b/app/views/admin/licenseseditor.py
diff --git a/app/views/tagseditor.py b/app/views/admin/tagseditor.py
index 7d88f28..7d88f28 100644
--- a/app/views/tagseditor.py
+++ b/app/views/admin/tagseditor.py
diff --git a/app/views/packages/todo.py b/app/views/admin/todo.py
index 47b8cb5..47b8cb5 100644
--- a/app/views/packages/todo.py
+++ b/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 <https://www.gnu.org/licenses/>.
-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 <https://www.gnu.org/licenses/>.
+
+
+from . import users, githublogin, notifications
diff --git a/app/views/githublogin.py b/app/views/users/githublogin.py
index 9ea2584..9ea2584 100644
--- a/app/views/githublogin.py
+++ b/app/views/users/githublogin.py
diff --git a/app/views/notifications.py b/app/views/users/notifications.py
index 23dbb31..23dbb31 100644
--- a/app/views/notifications.py
+++ b/app/views/users/notifications.py
diff --git a/app/views/users.py b/app/views/users/users.py
index 6317d6b..6317d6b 100644
--- a/app/views/users.py
+++ b/app/views/users/users.py