]> ToastFreeware Gitweb - philipp/winterrodeln/wradmin.git/commitdiff
rodelbahn_list.html now uses jinja2.
authorphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Wed, 27 Dec 2017 22:31:13 +0000 (22:31 +0000)
committerphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Wed, 27 Dec 2017 22:31:13 +0000 (22:31 +0000)
git-svn-id: http://www.winterrodeln.org/svn/wradmin/trunk@2757 7aebc617-e5e2-0310-91dc-80fb5f6d2477

wradmin/controllers/rodelbahn.py
wradmin/templates/rodelbahn_list.html

index 66107f24f21d5e5c40706f53d11d38963b9efe1f..32654a85328f3feabd454ab5e26dfae3c9d9ad2a 100644 (file)
@@ -1,5 +1,5 @@
 #!/usr/bin/python3.4
-from flask import request, abort, redirect, url_for, flash
+from flask import request, abort, redirect, url_for, flash, render_template
 import paginate
 import sqlalchemy as sa
 
@@ -17,11 +17,10 @@ class RodelbahnController:
         """Lists all sled runs"""
         q = model.meta.Session.query(model.WrSledrunCache)
         q = q.order_by(model.WrSledrunCache.page_title)
-        c = TemplateContext()
-        c.paginator = paginate.Page(q.all(), page=int(request.args.get('page', 1)),
-                                    url_maker=lambda page: url_for('rodelbahn_list', page=page),
-                                    items_per_page=25)
-        return render_genshi_template('rodelbahn_list.html', c=c)
+        paginator = paginate.Page(q.all(), page=int(request.args.get('page', 1)),
+                                  url_maker=lambda page: url_for('rodelbahn_list', page=page),
+                                  items_per_page=25)
+        return render_template('rodelbahn_list.html', paginator=paginator)
 
     def view(self, id):
         """Displays a sled run"""
index 754ef89952184fe6ceeabdf22dbbbc7e5d4a0029..e67900d4bc06f50800a0503b29c7477b7931af20 100644 (file)
@@ -1,71 +1,63 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
-                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml"
-    xmlns:py="http://genshi.edgewall.org/"
-    xmlns:xi="http://www.w3.org/2001/XInclude">
-<xi:include href="master.html" />
+{% extends "master.html" %}
+{% block title %}Rodelbahnen{% endblock %}
 
-<head>
-    <title>Rodelbahnen</title>
-</head>
-
-<body>
+{% block content %}
 <h2>Rodelbahnen</h2>
 
-<p>Die folgende Lise wurde automatisiert von den Rodelbahnboxen gesammelt. Da dies nicht automatisch passiert, kann es sein, dass die Liste "veraltete" Information enthält.</p>
+<p>Die folgende Lise wurde automatisiert von den Rodelbahnboxen gesammelt. Da dies nicht automatisch passiert, kann es sein, dass die Liste "veraltete" Information enthält.</p>
 
-<a href="${h.url(controller='rodelbahn', action='update')}" class="button">(1) Rodelbahnboxen auslesen und DB aktualisieren</a>
-<a href="${h.url(controller='rodelbahn', action='update_regioncache')}" class="button">(2) Rodelbahnen in den Regionslisten aktualisieren</a>
+<a href="{{url_for('rodelbahn_update')}}" class="button">(1) Rodelbahnboxen auslesen und DB aktualisieren</a>
+<a href="{{url_for('rodelbahn_update_regioncache')}}" class="button">(2) Rodelbahnen in den Regionslisten aktualisieren</a>
 
-<p>${Markup(c.paginator.pager('$link_first $link_previous $first_item bis $last_item von $item_count $link_next $link_last'))}</p>
+<p>{{paginator.pager('$link_first $link_previous $first_item bis $last_item von $item_count $link_next $link_last') | safe}}</p>
 
 <table>
     <tr>
         <th>ID</th>
         <th>Name</th>
-        <th>Länge</th>
+        <th>Länge</th>
         <th>Gehzeit</th>
-        <th>Höhe (oben)</th>
-        <th>Höhe (unten)</th>
-        <th>Aufstieg möglich</th>
+        <th>Höhe (oben)</th>
+        <th>Höhe (unten)</th>
+        <th>Aufstieg möglich</th>
         <th>Aufstieg getrennt</th>
         <th>Lift</th>
         <th>Licht</th>
         <th>Rodelverleih</th>
-        <th>Öffentl. Anreise</th>
+        <th>Öffentl. Anreise</th>
         <th>Bild</th>
         <th>Latitude</th>
         <th>Longitude</th>
         <th>Information</th>
         <th>Forum-ID</th>
         <th>In Arbeit</th>
-        <th>In Übersicht</th>
+        <th>In Übersicht</th>
     </tr>
-    <tr py:for="s in c.paginator">
-        <td><a href="${h.url(controller='rodelbahn', action='view', id=s.page_id)}">${s.page_id}</a></td>
-        <td>${s.page_title}</td>
-        <td>${s.length}</td>
-        <td>${s.walkup_time}</td>
-        <td>${s.top_elevation}</td>
-        <td>${s.bottom_elevation}</td>
-        <td>${h.bool(s.walkup_possible)}</td>
-        <td>${h.tristate_float(s.walkup_separate)}</td>
-        <td>${h.bool(s.lift)}</td>
-        <td>${h.tristate_float(s.night_light)}</td>
-        <td>${h.bool(s.sled_rental)}</td>
-        <td>${h.public_transport(s.public_transport)}</td>
-        <td><small>${s.image}</small></td>
-        <td>${s.position_latitude}</td>
-        <td>${s.position_longitude}</td>
-        <td>${s.information_phone}</td>
-        <td>${s.forum_id}</td>
-        <td>${h.bool(s.under_construction)}</td>
-        <td>${h.bool(s.show_in_overview)}</td>
+    {% for s in paginator %}
+    <tr>
+        <td><a href="{{url_for('rodelbahn_view', id=s.page_id)}}">{{s.page_id}}</a></td>
+        <td>{{s.page_title}}</td>
+        <td>{{s.length}}</td>
+        <td>{{s.walkup_time}}</td>
+        <td>{{s.top_elevation}}</td>
+        <td>{{s.bottom_elevation}}</td>
+        <td>{{h.bool(s.walkup_possible)}}</td>
+        <td>{{h.tristate_float(s.walkup_separate)}}</td>
+        <td>{{h.bool(s.lift)}}</td>
+        <td>{{h.tristate_float(s.night_light)}}</td>
+        <td>{{h.bool(s.sled_rental)}}</td>
+        <td>{{h.public_transport(s.public_transport)}}</td>
+        <td><small>{{s.image}}</small></td>
+        <td>{{s.position_latitude}}</td>
+        <td>{{s.position_longitude}}</td>
+        <td>{{s.information_phone}}</td>
+        <td>{{s.forum_id}}</td>
+        <td>{{h.bool(s.under_construction)}}</td>
+        <td>{{h.bool(s.show_in_overview)}}</td>
     </tr>
+    {% endfor %}
 </table>
 
-<p>${Markup(c.paginator.pager('~2~'))}</p>
+<p>{{paginator.pager('~2~') | safe}}</p>
 
-</body>
-</html>
+{% endblock %}