From d1e1c687393897e41c6ed228842d53d9f80ca30d Mon Sep 17 00:00:00 2001 From: Antanas Uršulis Date: Wed, 31 Jul 2013 04:42:57 +0300 Subject: Group list view --- database.py | 5 +++++ flask_app.py | 4 ++-- templates/base.html | 13 +++++++++++++ templates/group_list.html | 20 ++++++++++++++++++++ 4 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 templates/base.html create mode 100644 templates/group_list.html diff --git a/database.py b/database.py index 9927627..5f14801 100644 --- a/database.py +++ b/database.py @@ -17,6 +17,11 @@ class DatabaseConnection(object): self.conn.commit() return c.lastrowid + def get_groups(self): + with closing(self.conn.cursor(MySQLdb.cursors.DictCursor)) as c: + c.execute("select * from `groups`") + return c.fetchall() + def get_connection(user, passwd, db): conn = MySQLdb.connect(user=user, passwd=passwd, db=db) return DatabaseConnection(conn) diff --git a/flask_app.py b/flask_app.py index 17281fa..67b2217 100644 --- a/flask_app.py +++ b/flask_app.py @@ -5,7 +5,7 @@ When run as a script, the Flask development server is started. import os, socket import submission_pb2, storage, database -from flask import Flask, request, g +from flask import Flask, request, g, render_template from portage_processor import PortageProcessor @@ -25,7 +25,7 @@ def teardown_request(exception): @app.route('/') def index(): - pass + return render_template('group_list.html', groups=g.db.get_groups()) @app.route('/submit', methods=['POST']) def submit(): diff --git a/templates/base.html b/templates/base.html new file mode 100644 index 0000000..4d0a7ad --- /dev/null +++ b/templates/base.html @@ -0,0 +1,13 @@ + + + + {% block head %} + {% block title %}{% endblock %} + {% endblock %} + + + + {% block body %} + {% endblock %} + + diff --git a/templates/group_list.html b/templates/group_list.html new file mode 100644 index 0000000..325eec5 --- /dev/null +++ b/templates/group_list.html @@ -0,0 +1,20 @@ +{% extends "base.html" %} +{% block title %}List of log groups{% endblock %} +{% block body %} + + + + + + + + {% for group in groups %} + + + + + + + {% endfor %} +
hostnamegroup nameproviderdate
{{ group.hostname }}{{ group.name }}{{ group.provider }}{{ group.date }}
+{% endblock %} -- cgit v1.2.3-65-gdbad