1 |
commit: d1e1c687393897e41c6ed228842d53d9f80ca30d |
2 |
Author: Antanas Uršulis <antanas.ursulis <AT> gmail <DOT> com> |
3 |
AuthorDate: Wed Jul 31 01:42:57 2013 +0000 |
4 |
Commit: Antanas Ursulis <antanas.ursulis <AT> gmail <DOT> com> |
5 |
CommitDate: Wed Jul 31 01:42:57 2013 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/log-analysis.git;a=commit;h=d1e1c687 |
7 |
|
8 |
Group list view |
9 |
|
10 |
--- |
11 |
database.py | 5 +++++ |
12 |
flask_app.py | 4 ++-- |
13 |
templates/base.html | 13 +++++++++++++ |
14 |
templates/group_list.html | 20 ++++++++++++++++++++ |
15 |
4 files changed, 40 insertions(+), 2 deletions(-) |
16 |
|
17 |
diff --git a/database.py b/database.py |
18 |
index 9927627..5f14801 100644 |
19 |
--- a/database.py |
20 |
+++ b/database.py |
21 |
@@ -17,6 +17,11 @@ class DatabaseConnection(object): |
22 |
self.conn.commit() |
23 |
return c.lastrowid |
24 |
|
25 |
+ def get_groups(self): |
26 |
+ with closing(self.conn.cursor(MySQLdb.cursors.DictCursor)) as c: |
27 |
+ c.execute("select * from `groups`") |
28 |
+ return c.fetchall() |
29 |
+ |
30 |
def get_connection(user, passwd, db): |
31 |
conn = MySQLdb.connect(user=user, passwd=passwd, db=db) |
32 |
return DatabaseConnection(conn) |
33 |
|
34 |
diff --git a/flask_app.py b/flask_app.py |
35 |
index 17281fa..67b2217 100644 |
36 |
--- a/flask_app.py |
37 |
+++ b/flask_app.py |
38 |
@@ -5,7 +5,7 @@ When run as a script, the Flask development server is started. |
39 |
|
40 |
import os, socket |
41 |
import submission_pb2, storage, database |
42 |
-from flask import Flask, request, g |
43 |
+from flask import Flask, request, g, render_template |
44 |
|
45 |
from portage_processor import PortageProcessor |
46 |
|
47 |
@@ -25,7 +25,7 @@ def teardown_request(exception): |
48 |
|
49 |
@app.route('/') |
50 |
def index(): |
51 |
- pass |
52 |
+ return render_template('group_list.html', groups=g.db.get_groups()) |
53 |
|
54 |
@app.route('/submit', methods=['POST']) |
55 |
def submit(): |
56 |
|
57 |
diff --git a/templates/base.html b/templates/base.html |
58 |
new file mode 100644 |
59 |
index 0000000..4d0a7ad |
60 |
--- /dev/null |
61 |
+++ b/templates/base.html |
62 |
@@ -0,0 +1,13 @@ |
63 |
+<!DOCTYPE html> |
64 |
+<html> |
65 |
+ <head> |
66 |
+ {% block head %} |
67 |
+ <title>{% block title %}{% endblock %}</title> |
68 |
+ {% endblock %} |
69 |
+ </head> |
70 |
+ |
71 |
+ <body> |
72 |
+ {% block body %} |
73 |
+ {% endblock %} |
74 |
+ </body> |
75 |
+</html> |
76 |
|
77 |
diff --git a/templates/group_list.html b/templates/group_list.html |
78 |
new file mode 100644 |
79 |
index 0000000..325eec5 |
80 |
--- /dev/null |
81 |
+++ b/templates/group_list.html |
82 |
@@ -0,0 +1,20 @@ |
83 |
+{% extends "base.html" %} |
84 |
+{% block title %}List of log groups{% endblock %} |
85 |
+{% block body %} |
86 |
+ <table> |
87 |
+ <tr> |
88 |
+ <th>hostname</th> |
89 |
+ <th>group name</th> |
90 |
+ <th>provider</th> |
91 |
+ <th>date</th> |
92 |
+ </tr> |
93 |
+ {% for group in groups %} |
94 |
+ <tr> |
95 |
+ <td>{{ group.hostname }}</td> |
96 |
+ <td>{{ group.name }}</td> |
97 |
+ <td>{{ group.provider }}</td> |
98 |
+ <td>{{ group.date }}</td> |
99 |
+ </tr> |
100 |
+ {% endfor %} |
101 |
+ </table> |
102 |
+{% endblock %} |