comparison display_issues.py @ 31:9aca070c86bd

Add the filter 'priority' for the search by status.
author Magnus Schieder <mschieder@intevation.de>
date Thu, 22 Nov 2018 19:34:53 +0100
parents 8d86ba8dee42
children 80bbd06fe8ec
comparison
equal deleted inserted replaced
30:0d6504d02a6b 31:9aca070c86bd
38 for item in array: 38 for item in array:
39 formated.append("{date : new Date('" + str(item) + "')}") 39 formated.append("{date : new Date('" + str(item) + "')}")
40 40
41 return ", ".join(formated) 41 return ", ".join(formated)
42 42
43 def get_webpage(data_dict, columns, status, keywords, graph=None): 43 def get_webpage(data_dict, columns, search_parameters, keywords, graph=None):
44 44
45 if graph is None: 45 if graph is None:
46 graph = os.path.dirname(os.path.realpath(__file__)) + '/graph.html' 46 graph = os.path.dirname(os.path.realpath(__file__)) + '/graph.html'
47 47
48 with open(graph, "r") as html_chart_file: 48 with open(graph, "r") as html_chart_file:
56 for col in columns.split(", "): 56 for col in columns.split(", "):
57 js_data_dickt += col + ":[" + make_js_object_string(data_dict[col]) + "]," 57 js_data_dickt += col + ":[" + make_js_object_string(data_dict[col]) + "],"
58 js_data_dickt += "}" 58 js_data_dickt += "}"
59 59
60 base_html_data = (base_html_data 60 base_html_data = (base_html_data
61 .replace("status", status) 61 .replace("search_parameters", search_parameters)
62 .replace("keywords", keywords) 62 .replace("keywords", keywords)
63 .replace("js_data_dickt", js_data_dickt) 63 .replace("js_data_dickt", js_data_dickt)
64 .replace("var timestamp=[];", "var timestamp=[" + make_js_object_date(data_dict["date"]) + "]")) 64 .replace("var timestamp=[];", "var timestamp=[" + make_js_object_date(data_dict["date"]) + "]"))
65 65
66 return base_html_data 66 return base_html_data
67 67
68 def compile_db_stats_html(db_file, sql_select, columns, status="", keywords="", graph=None): 68 def compile_db_stats_html(db_file, sql_select, columns, search_parameters="", keywords="", graph=None):
69 69
70 data_dict = {"date": []} 70 data_dict = {"date": []}
71 status_list = columns.split(", ") 71 status_list = columns.split(", ")
72 for x in status_list: 72 for x in status_list:
73 data_dict[x] = [] 73 data_dict[x] = []
89 if cur: 89 if cur:
90 cur.close() 90 cur.close()
91 if con: 91 if con:
92 con.close() 92 con.close()
93 93
94 return get_webpage(data_dict, columns, status, keywords, graph) 94 return get_webpage(data_dict, columns, search_parameters, keywords, graph)
95 95
96 def render_webpage(content): 96 def render_webpage(content):
97 for line in content.split("\n"): 97 for line in content.split("\n"):
98 print(line) 98 print(line)
99 99
100 def render_db_stats_as_html(db_file, sql_select, columns, status="", keywords=""): 100 def render_db_stats_as_html(db_file, sql_select, columns, search_parameters="", keywords=""):
101 render_webpage(compile_db_stats_html(db_file, sql_select, columns, status, keywords)) 101 render_webpage(compile_db_stats_html(db_file, sql_select, columns, search_parameters, keywords))
102 102
103 if __name__ == '__main__': 103 if __name__ == '__main__':
104 cgitb.enable() 104 cgitb.enable()
105 #spit out HTML file directly, thus no need to give headers to the server 105 #spit out HTML file directly, thus no need to give headers to the server
106 #print("Content-Type: text/html") 106 #print("Content-Type: text/html")
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)