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

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

Issue 8793015: Reports - user profile (Closed)
Patch Set: Reports - user profile Created Nov. 7, 2012, 9:38 a.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
(Empty)
1 # coding: utf-8
2
3 # This file is part of the Adblock Plus web scripts,
4 # Copyright (C) 2006-2012 Eyeo GmbH
5 #
6 # Adblock Plus is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License version 3 as
8 # published by the Free Software Foundation.
9 #
10 # Adblock Plus is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
17
18 import re
19 from urlparse import parse_qs
20 from sitescripts.reports.utils import getUser, getReportsForUser
21 from sitescripts.utils import get_config, get_template, setupStderr
22 from sitescripts.web import url_handler
23
24 @url_handler('/showUser')
25 def handleRequest(environ, start_response):
26 setupStderr(environ['wsgi.errors'])
27
28 params = parse_qs(environ.get('QUERY_STRING', ''))
29
30 id = params.get('id', [''])[0].lower()
31 if not re.match(r'^[\da-f]{32}$', id):
32 return showError('Invalid or missing ID', start_response)
33
34 user = getUser(id)
35 if user == None:
36 return showError('User not found', start_response)
37
38 user['reportlist'] = getReportsForUser(id)
39
40 template = get_template(get_config().get('reports', 'showUserTemplate'))
41 start_response('200 OK', [('Content-Type', 'application/xhtml+xml; charset=utf -8')])
42 return [template.render(user).encode('utf-8')]
43
44 def showError(message, start_response):
45 template = get_template(get_config().get('reports', 'errorTemplate'))
46 start_response('400 Processing Error', [('Content-Type', 'application/xhtml+xm l; charset=utf-8')])
47 return [template.render({'message': message}).encode('utf-8')]
OLDNEW

Powered by Google App Engine
This is Rietveld