changeset 7:99e2e0e17103

Adding possibility and example to filter the entries.
author Bernhard Reiter <bernhard@intevation.de>
date Tue, 01 Dec 2015 09:02:35 +0100
parents a1e71b5e4d68
children 4490a9f737da
files display_issues.py display_issues_demo.py roundup_content_data/__init__.py
diffstat 3 files changed, 20 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/display_issues.py	Tue Dec 01 09:01:52 2015 +0100
+++ b/display_issues.py	Tue Dec 01 09:02:35 2015 +0100
@@ -14,12 +14,7 @@
 
 
 ##Usage Example: ##
-
-from display_issues import *
-cgitb.enable() # (optional) HTML traceback to browser
-print("Content-Type: text/html")
-print()
-render_db_stats_as_html(rcd.DATABASE_DEMO, rcd.SELECT_ALL)
+see display_issues_demo.py or __main__ section below.
 """
 
 import sqlite3 as db
@@ -94,7 +89,8 @@
 
 if __name__ == '__main__':
     cgitb.enable()
-    print("Content-Type: text/html")
-    print()
+    #spit out HTML file directly, thus no need to give headers to the server
+    #print("Content-Type: text/html")
+    #print()
 
     render_db_stats_as_html(rcd.DATABASE_DEMO, rcd.SELECT_ALL)
--- a/display_issues_demo.py	Tue Dec 01 09:01:52 2015 +0100
+++ b/display_issues_demo.py	Tue Dec 01 09:02:35 2015 +0100
@@ -18,4 +18,6 @@
 cgitb.enable() # (optional) HTML traceback to browser
 print("Content-Type: text/html")
 print()
-render_db_stats_as_html(rcd.DATABASE_DEMO, rcd.SELECT_ALL)
+#render_db_stats_as_html(rcd.DATABASE_DEMO, rcd.SELECT_ALL)
+render_db_stats_as_html(rcd.DATABASE_DEMO,
+            rcd.SELECT_WHERE.format("timestamp > date('now', '-2 month')"))
--- a/roundup_content_data/__init__.py	Tue Dec 01 09:01:52 2015 +0100
+++ b/roundup_content_data/__init__.py	Tue Dec 01 09:02:35 2015 +0100
@@ -50,6 +50,18 @@
 ORDER BY timestamp
 """
 
+SELECT_WHERE = """
+SELECT strftime("%Y-%m-%dT%H:%M:%S", timestamp),
+    critical,
+    urgent,
+    bug,
+    feature,
+    wish
+FROM issues
+WHERE {}
+ORDER BY timestamp
+"""
+
 
 CREATE_DB = """
 CREATE TABLE issues (
@@ -79,4 +91,4 @@
     wishlist
 FROM issues
 ORDER BY sample_time
-"""
\ No newline at end of file
+"""
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)