summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntanas Uršulis <antanas.ursulis@gmail.com>2013-07-31 04:42:57 +0300
committerAntanas Uršulis <antanas.ursulis@gmail.com>2013-07-31 04:42:57 +0300
commitd1e1c687393897e41c6ed228842d53d9f80ca30d (patch)
treebbe9db83409901634be071c722f8387f280ef326
parentAdd TODO item (diff)
downloadlog-analysis-d1e1c687393897e41c6ed228842d53d9f80ca30d.tar.gz
log-analysis-d1e1c687393897e41c6ed228842d53d9f80ca30d.tar.bz2
log-analysis-d1e1c687393897e41c6ed228842d53d9f80ca30d.zip
Group list view
-rw-r--r--database.py5
-rw-r--r--flask_app.py4
-rw-r--r--templates/base.html13
-rw-r--r--templates/group_list.html20
4 files changed, 40 insertions, 2 deletions
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 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ {% block head %}
+ <title>{% block title %}{% endblock %}</title>
+ {% endblock %}
+ </head>
+
+ <body>
+ {% block body %}
+ {% endblock %}
+ </body>
+</html>
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 %}
+ <table>
+ <tr>
+ <th>hostname</th>
+ <th>group name</th>
+ <th>provider</th>
+ <th>date</th>
+ </tr>
+ {% for group in groups %}
+ <tr>
+ <td>{{ group.hostname }}</td>
+ <td>{{ group.name }}</td>
+ <td>{{ group.provider }}</td>
+ <td>{{ group.date }}</td>
+ </tr>
+ {% endfor %}
+ </table>
+{% endblock %}