]> git.ipfire.org Git - ipfire.org.git/commitdiff
blog: Remove unneeded backend functions
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 27 Jul 2023 09:09:28 +0000 (09:09 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 27 Jul 2023 09:09:28 +0000 (09:09 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/backend/blog.py
src/web/blog.py

index a626cb2e774981b8bc9de2e895af1a13e20fbc2e..b21c9aa9056bda1b26045fa2dfbfcb11f968d093 100644 (file)
@@ -49,14 +49,6 @@ class Blog(misc.Object):
                                AND %s = ANY(tags) \
                        ORDER BY published_at DESC LIMIT %s", tag, limit)
 
-       def get_by_author(self, author, limit=None):
-               return self._get_posts("SELECT * FROM blog \
-                       WHERE (author = %s OR author_uid = %s) \
-                               AND published_at IS NOT NULL \
-                               AND published_at <= NOW() \
-                       ORDER BY published_at DESC LIMIT %s",
-                       author.name, author.uid, limit)
-
        def get_by_year(self, year):
                return self._get_posts("SELECT * FROM blog \
                        WHERE EXTRACT(year FROM published_at) = %s \
@@ -64,17 +56,12 @@ class Blog(misc.Object):
                                AND published_at <= NOW() \
                        ORDER BY published_at DESC", year)
 
-       def get_drafts(self, author=None, limit=None):
-               if author:
-                       return self._get_posts("SELECT * FROM blog \
-                               WHERE author_uid = %s \
-                                       AND (published_at IS NULL OR published_at > NOW()) \
-                               ORDER BY COALESCE(updated_at, created_at) DESC LIMIT %s",
-                               author.uid, limit)
-
+       def get_drafts(self, author, limit=None):
                return self._get_posts("SELECT * FROM blog \
-                       WHERE (published_at IS NULL OR published_at > NOW()) \
-                       ORDER BY COALESCE(updated_at, created_at) DESC LIMIT %s", limit)
+                       WHERE author_uid = %s \
+                               AND (published_at IS NULL OR published_at > NOW()) \
+                       ORDER BY COALESCE(updated_at, created_at) DESC LIMIT %s",
+                       author.uid, limit)
 
        def search(self, query, limit=None):
                posts = self._get_posts("SELECT blog.* FROM blog \
@@ -163,29 +150,6 @@ class Blog(misc.Object):
                for row in res:
                        yield row.year
 
-       @property
-       def authors(self):
-               res = self.db.query("""
-                       SELECT
-                               author_uid,
-                               MAX(published_at) AS published_at
-                       FROM
-                               blog
-                       WHERE
-                               author_uid IS NOT NULL
-                       AND
-                               published_at IS NOT NULL
-                       AND
-                               published_at <= NOW()
-                       GROUP BY
-                               author_uid
-                       ORDER BY
-                               published_at DESC
-                       """,
-               )
-
-               return [self.backend.accounts.get_by_uid(row.author_uid) for row in res]
-
        async def announce(self):
                posts = self._get_posts("SELECT * FROM blog \
                        WHERE (published_at IS NOT NULL AND published_at <= NOW()) \
index 7ff5f06050ebe236c0e1a95f83cf1551cb1ee903..a2ac1e3285f48b7c27ff33195c6e1cd6e0e9e159 100644 (file)
@@ -238,7 +238,7 @@ class DeleteHandler(base.BaseHandler):
 class HistoryNavigationModule(ui_modules.UIModule):
        def render(self):
                return self.render_string("blog/modules/history-navigation.html",
-                       authors=self.backend.blog.authors, years=self.backend.blog.years)
+                       years=self.backend.blog.years)
 
 
 class ListModule(ui_modules.UIModule):