Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(418)

Side by Side Diff: chromium-committers/app.py

Issue 25515004: Add chromium-committers appengine app. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chromium-committers/app.yaml » ('j') | chromium-committers/auth_util.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 """This file handles serving the list of committers to users."""
6
7 __author__ = 'agable@google.com (Aaron Gable)'
8
9
10 import webapp2
11
12 from google.appengine.api import users
13 from google.appengine.ext import ndb
14
15 import auth_util
16 import constants
17 import model
18
19
20 class ChromiumHandler(webapp2.RequestHandler):
21
22 @staticmethod
23 def _can_see_list(user, committer_list):
24 """Returns True if the user is allowed to see the list."""
25 if not user:
26 return False
27 if users.is_current_user_admin():
28 return True
29 email = user.email()
30 if email in committer_list:
31 return True
32 if (email.endswith('@google.com') and
33 email[:-11] + '@chromium.org' in committer_list):
34 return True
35 return False
36
37 def get(self):
38 """Displays the list of chromium committers in plain text."""
39 self.response.headers['Content-Type'] = 'text/plain'
40
41 committer_list = ndb.Key(model.EmailList, constants.LIST).get()
42 emails = committer_list.emails if committer_list else []
43
44 authenticated = False
45 try:
46 auth_util.CheckRequest(self.request)
47 authenticated = True
48 except:
49 user = users.get_current_user()
50 authenticated = self._can_see_list(user, emails)
51
52 if authenticated:
53 self.response.write('\n'.join(sorted(emails)))
54 else:
55 self.response.status = 403
56 self.response.write('403: Forbidden')
57
58
59 class MappingHandler(webapp2.RequestHandler):
60
61 def get(self):
62 """Displays the mapping of chromium to googler email addresses."""
63 self.response.headers['Content-Type'] = 'text/plain'
64 self.response.out.write('Not yet implemented. Sorry!')
65
66
67 class UpdateHandler(webapp2.RequestHandler):
68 def post(self):
69 """Updates the list of committers from the POST data recieved."""
70 auth_util.CheckRequest(self.request)
71 emails = request.get('committers')
72 committer_list = model.EmailList(id=constants.LIST, emails=emails)
73 committer_list.put()
74
75
76 app = webapp2.WSGIApplication([
77 ('/chromium', ChromiumHandler),
78 ('/mapping', MappingHandler),
79 ('/update', UpdateHandler),
80 ], debug=True)
OLDNEW
« no previous file with comments | « no previous file | chromium-committers/app.yaml » ('j') | chromium-committers/auth_util.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698