Changeset 3014
- Timestamp:
- 01/09/08 15:35:07 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
estimatorplugin/0.11/estimatorplugin/dbhelper.py
r3013 r3014 121 121 def get_result_set(sql, *params): 122 122 """Executes the query and returns a Result Set""" 123 return ResultSet(get_all(sql, *params)) 123 tpl = get_all(sql, *params); 124 if tpl and tpl[0] and tpl[1]: 125 return ResultSet(tpl) 126 else: 127 return None 124 128 125 129 … … 162 166 print ("rs.value Type Failed col:%s row:%s" % (type(col), type(row))) 163 167 168 def json_out(self): 169 return "[%s]" % ','. join( 170 [("{%s}" % ','.join(["'%s':%r" %(key, self.value(val, row)) 171 for (key, val) in columnMap.items()])) 172 for row in rows]) estimatorplugin/0.11/estimatorplugin/templates/estimate.html
r3013 r3014 35 35 <tr> 36 36 <td ><label for="rate">Rate</label></td> 37 <td><input id="rate" type="text" onkeyup="runCalculation()" value=" " /></td>37 <td><input id="rate" type="text" onkeyup="runCalculation()" value="${estimate.rate}" /></td> 38 38 </tr> 39 39 <tr> 40 40 <td ><label for="variability">Variability</label></td> 41 <td><input id="variability" type="text" onkeyup="runCalculation()" value=" " /></td>41 <td><input id="variability" type="text" onkeyup="runCalculation()" value="${estimate.variability}" /></td> 42 42 </tr> 43 43 <tr> 44 44 <td ><label for="communication">Communication</label></td> 45 <td><input id="communication" type="text" onkeyup="runCalculation()" value=" " /></td>45 <td><input id="communication" type="text" onkeyup="runCalculation()" value="${estimate.communication}" /></td> 46 46 </tr> 47 47 </table> … … 82 82 </table> 83 83 <script language="javascript" > 84 var lineItems = [ 85 <py:for each="item in estimate.lineitems" > 86 </py:for> 87 ]; 84 var lineItems = ${estimate.lineItems}; 88 85 loadLineItems( ); 89 86 newLineItem(); estimatorplugin/0.11/estimatorplugin/webui.py
r3013 r3014 1 1 import re 2 import dbhelper 2 3 from pkg_resources import resource_filename 3 4 from trac.core import * … … 30 31 return req.path_info.startswith('/Estimate') 31 32 33 def load(self, req, addMessage, data): 34 try: 35 id = int(req.args['id']) 36 data["estimate"]["id"] = id 37 estimate_rs = dbhelper.get_result_set("SELECT * FROM estimate WHERE estimate_id=%s", id) 38 if estimate_rs: 39 data["estimate"]["rate"] = estimate_rs.get_value("rate", 0) 40 data["estimate"]["variability"] = estimate_rs.get_value("variability", 0) 41 data["estimate"]["communication"] = estimate_rs.get_value("communication", 0) 42 rs = dbhelper.get_result_set("SELECT * FROM estimate_line_item WHERE estimate_id=%s", id) 43 if rs: 44 data["estimate"]["lineItems"] = rs.json_out() 45 else: 46 addMessage('Cant Find Estimate Id: %s' % id) 47 except Exception, e: 48 addMessage('Invalid Id: %s' % id) 49 addMessage('Error: %s' % e) 50 32 51 def process_request(self, req): 33 52 messages = [] … … 39 58 data["estimate"]={"href": req.href.Estimate(), 40 59 "messages": messages, 41 "lineitems": [], 42 } 60 "lineItems": '[]', 61 "rate": self.config.get( 'estimator','default_rate') or 200, 62 "variability": self.config.get( 'estimator','default_variability') or 1, 63 "communication": self.config.get( 'estimator','default_communication') or 1, 64 } 65 66 if req.args.has_key('id'): 67 self.load(req, addMessage, data) 68 69 43 70 add_script(req, "Estimate/JSHelper.js") 44 71 add_script(req, "Estimate/Controls.js")
