1 |
commit: 5c567070fc3a18ae08c7d4b5ffa9af5ae3a72e5e |
2 |
Author: Antanas Uršulis <antanas.ursulis <AT> gmail <DOT> com> |
3 |
AuthorDate: Fri Aug 2 07:12:25 2013 +0000 |
4 |
Commit: Antanas Ursulis <antanas.ursulis <AT> gmail <DOT> com> |
5 |
CommitDate: Fri Aug 2 07:12:25 2013 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/log-analysis.git;a=commit;h=5c567070 |
7 |
|
8 |
Simple file list template |
9 |
|
10 |
TODO: it should provide a link to file, instead of printing the path. |
11 |
|
12 |
--- |
13 |
database.py | 5 +++++ |
14 |
flask_app.py | 4 ++++ |
15 |
templates/file_list.html | 16 ++++++++++++++++ |
16 |
3 files changed, 25 insertions(+) |
17 |
|
18 |
diff --git a/database.py b/database.py |
19 |
index 5f14801..29b687a 100644 |
20 |
--- a/database.py |
21 |
+++ b/database.py |
22 |
@@ -21,6 +21,11 @@ class DatabaseConnection(object): |
23 |
with closing(self.conn.cursor(MySQLdb.cursors.DictCursor)) as c: |
24 |
c.execute("select * from `groups`") |
25 |
return c.fetchall() |
26 |
+ |
27 |
+ def get_files(self): |
28 |
+ with closing(self.conn.cursor(MySQLdb.cursors.DictCursor)) as c: |
29 |
+ c.execute("select `files`.* from `files` inner join `groups` on `files`.`group_id` = `groups`.`id` order by `groups`.`date` desc") |
30 |
+ return c.fetchall() |
31 |
|
32 |
def get_connection(user, passwd, db): |
33 |
conn = MySQLdb.connect(user=user, passwd=passwd, db=db) |
34 |
|
35 |
diff --git a/flask_app.py b/flask_app.py |
36 |
index 67b2217..6eeaa0c 100644 |
37 |
--- a/flask_app.py |
38 |
+++ b/flask_app.py |
39 |
@@ -27,6 +27,10 @@ def teardown_request(exception): |
40 |
def index(): |
41 |
return render_template('group_list.html', groups=g.db.get_groups()) |
42 |
|
43 |
+@×××.route('/files') |
44 |
+def file_list(): |
45 |
+ return render_template('file_list.html', files=g.db.get_files()) |
46 |
+ |
47 |
@app.route('/submit', methods=['POST']) |
48 |
def submit(): |
49 |
submission = submission_pb2.Submission() |
50 |
|
51 |
diff --git a/templates/file_list.html b/templates/file_list.html |
52 |
new file mode 100644 |
53 |
index 0000000..8980776 |
54 |
--- /dev/null |
55 |
+++ b/templates/file_list.html |
56 |
@@ -0,0 +1,16 @@ |
57 |
+{% extends "base.html" %} |
58 |
+{% block title %}List of log files{% endblock %} |
59 |
+{% block body %} |
60 |
+ <table> |
61 |
+ <tr> |
62 |
+ <th>group id</th> |
63 |
+ <th>path</th> |
64 |
+ </tr> |
65 |
+ {% for file in files %} |
66 |
+ <tr> |
67 |
+ <td>{{ file.group_id }}</td> |
68 |
+ <td>{{ file.path }}</td> |
69 |
+ </tr> |
70 |
+ {% endfor %} |
71 |
+ </table> |
72 |
+{% endblock %} |