]> git.ipfire.org Git - people/shoehn/ipfire.org.git/blobdiff - webapp/handlers_admin.py
mirrors: Sort by distance (ascending)
[people/shoehn/ipfire.org.git] / webapp / handlers_admin.py
index 97562c766c552ee964352886e1096efa1ad37976..b7a3f9d1bd94b5e86d8a105ad4ea0477d04b5432 100644 (file)
@@ -8,35 +8,7 @@ from handlers_base import *
 import backend
 
 class AdminBaseHandler(BaseHandler):
-       @property
-       def downloads(self):
-               return backend.Downloads()
-
-       def get_current_user(self):
-               return self.get_secure_cookie("account")
-
-
-class AdminLoginHandler(AdminBaseHandler):
-       def get(self):
-               self.render("admin-login.html")
-
-       def post(self):
-               account = self.accounts.search(self.get_argument("name"))
-               if not account:
-                       raise tornado.web.HTTPError(403)
-
-               if account.check_password(self.get_argument("password")):
-                       self.set_secure_cookie("account", account.uid)
-               else:
-                       raise tornado.web.HTTPError(403)
-
-               self.redirect("/")
-
-
-class AdminLogoutHandler(AdminBaseHandler):
-       def get(self):
-               self.clear_cookie("account")
-               self.redirect("/")
+       pass
 
 
 class AdminIndexHandler(AdminBaseHandler):
@@ -60,7 +32,7 @@ class AdminApiPlanetRenderMarkupHandler(AdminBaseHandler):
 class AdminPlanetHandler(AdminBaseHandler):
        @tornado.web.authenticated
        def get(self):
-               entries = self.planet.get_entries(status=None, limit=100)
+               entries = self.planet.get_entries(status=None, limit=50)
 
                self.render("admin-planet.html", entries=entries)
 
@@ -81,14 +53,12 @@ class AdminPlanetComposeHandler(AdminBaseHandler):
        def post(self):
                title = self.get_argument("title")
                markdown = self.get_argument("markdown")
-               tags = self.get_argument("tags", "")
 
                status = self.get_argument("status", "draft")
-
-               author = self.accounts.find(self.current_user)
+               assert status in ("draft", "published")
 
                entry = self.planet.create(title=title, markdown=markdown,
-                       author=author, status=status, tags=tags.split())
+                       author=self.current_user, status=status)
 
                self.redirect("/planet")
 
@@ -102,7 +72,6 @@ class AdminPlanetEditHandler(AdminPlanetComposeHandler):
 
                entry.title = self.get_argument("title")
                entry.markdown = self.get_argument("markdown")
-               entry.tags = self.get_argument("tags", "").split()
 
                entry.status = self.get_argument("status", "draft")
 
@@ -155,15 +124,13 @@ class AdminAccountsDeleteHandler(AdminAccountsBaseHandler):
 
 
 class AdminMirrorsBaseHandler(AdminBaseHandler):
-       @property
-       def mirrors(self):
-               return backend.Mirrors()
+       pass
 
 
 class AdminMirrorsHandler(AdminMirrorsBaseHandler):
        @tornado.web.authenticated
        def get(self):
-               mirrors = self.mirrors.list()
+               mirrors = self.mirrors.get_all()
 
                self.render("admin-mirrors.html", mirrors=mirrors)
 
@@ -179,7 +146,7 @@ class AdminMirrorsCreateHandler(AdminMirrorsBaseHandler):
        @tornado.web.authenticated
        def get(self, id=None):
                if id:
-                       mirror = self.db.get("SELECT * FROM mirrors WHERE id = '%s'", int(id))
+                       mirror = self.db.get("SELECT * FROM mirrors WHERE id = %s", id)
                else:
                        mirror = tornado.database.Row(
                                id="",
@@ -258,7 +225,7 @@ class AdminNewsBaseHandler(AdminBaseHandler):
 class AdminNewsHandler(AdminNewsBaseHandler):
        @tornado.web.authenticated
        def get(self):
-               news = self.news.list()
+               news = self.news.get_all()
 
                self.render("admin-news.html", news=news)