Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: sitescripts/reports/web/updateReport.py

Issue 8625042: Reports - user usefullness (Closed)
Patch Set: Reports - report update UI Created Oct. 18, 2012, 1:35 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 # coding: utf-8 1 # coding: utf-8
2 2
3 # This Source Code is subject to the terms of the Mozilla Public License 3 # This Source Code is subject to the terms of the Mozilla Public License
4 # version 2.0 (the "License"). You can obtain a copy of the License at 4 # version 2.0 (the "License"). You can obtain a copy of the License at
5 # http://mozilla.org/MPL/2.0/. 5 # http://mozilla.org/MPL/2.0/.
6 6
7 import re, os, sys, random 7 import re, os, sys, random
8 from urlparse import parse_qsl 8 from urlparse import parse_qsl
9 from sitescripts.utils import get_config, get_template, setupStderr 9 from sitescripts.utils import get_config, get_template, setupStderr
10 from sitescripts.web import url_handler 10 from sitescripts.web import url_handler
(...skipping 26 matching lines...) Expand all
37 return showError('Report does not exist', start_response) 37 return showError('Report does not exist', start_response)
38 38
39 secret = calculateReportSecret(guid) 39 secret = calculateReportSecret(guid)
40 if params.get('secret', '') != secret and params.get('secret', '') != calculat eReportSecret_compat(guid): 40 if params.get('secret', '') != secret and params.get('secret', '') != calculat eReportSecret_compat(guid):
41 return showError('Wrong secret value', start_response) 41 return showError('Wrong secret value', start_response)
42 42
43 reportData['status'] = params.get('status', '') 43 reportData['status'] = params.get('status', '')
44 if len(reportData['status']) > 1024: 44 if len(reportData['status']) > 1024:
45 reportData['status'] = reportData['status'][:1024] 45 reportData['status'] = reportData['status'][:1024]
46 46
47 if (reportData.get('email', None)):
48 reportData['utility'] = params.get('utility', 0)
Wladimir Palant 2012/10/18 15:41:24 Isn't this value a string? The default value shoul
Andrey Novikov 2012/10/18 15:51:29 Done.
49
47 saveReport(guid, reportData) 50 saveReport(guid, reportData)
48 51
49 if params.get('notify', '') and 'email' in reportData: 52 if params.get('notify', '') and 'email' in reportData:
50 email = reportData['email'] 53 email = reportData['email']
51 email = re.sub(r' at ', r'@', email) 54 email = re.sub(r' at ', r'@', email)
52 email = re.sub(r' dot ', r'.', email) 55 email = re.sub(r' dot ', r'.', email)
53 if re.match(r'^[\w.%+-]+@[\w.%+-]+(\.[\w.%+-]+)+', email): 56 if re.match(r'^[\w.%+-]+@[\w.%+-]+(\.[\w.%+-]+)+', email):
54 sendUpdateNotification({ 57 sendUpdateNotification({
55 'email': email, 58 'email': email,
56 'url': get_config().get('reports', 'urlRoot') + guid, 59 'url': get_config().get('reports', 'urlRoot') + guid,
57 'status': reportData['status'], 60 'status': reportData['status'],
58 }) 61 })
59 62
60 newURL = get_config().get('reports', 'urlRoot') + guid 63 newURL = get_config().get('reports', 'urlRoot') + guid
61 newURL += '?updated=' + str(int(random.uniform(0, 10000))) 64 newURL += '?updated=' + str(int(random.uniform(0, 10000)))
62 newURL += '#secret=' + secret 65 newURL += '#secret=' + secret
63 start_response('302 Found', [('Location', newURL.encode('utf-8'))]) 66 start_response('302 Found', [('Location', newURL.encode('utf-8'))])
64 return [] 67 return []
65 68
66 def showError(message, start_response): 69 def showError(message, start_response):
67 template = get_template(get_config().get('reports', 'errorTemplate')) 70 template = get_template(get_config().get('reports', 'errorTemplate'))
68 start_response('400 Processing Error', [('Content-Type', 'application/xhtml+xm l; charset=utf-8')]) 71 start_response('400 Processing Error', [('Content-Type', 'application/xhtml+xm l; charset=utf-8')])
69 return [template.render({'message': message}).encode('utf-8')] 72 return [template.render({'message': message}).encode('utf-8')]
OLDNEW
« sitescripts/reports/static/reports.js ('K') | « sitescripts/reports/template/report.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld