| Index: chromium-committers/app.py
|
| ===================================================================
|
| --- chromium-committers/app.py (revision 0)
|
| +++ chromium-committers/app.py (revision 0)
|
| @@ -0,0 +1,80 @@
|
| +# Copyright (c) 2013 The Chromium Authors. All rights reserved.
|
| +# Use of this source code is governed by a BSD-style license that can be
|
| +# found in the LICENSE file.
|
| +
|
| +"""This file handles serving the list of committers to users."""
|
| +
|
| +__author__ = 'agable@google.com (Aaron Gable)'
|
| +
|
| +
|
| +import webapp2
|
| +
|
| +from google.appengine.api import users
|
| +from google.appengine.ext import ndb
|
| +
|
| +import auth_util
|
| +import constants
|
| +import model
|
| +
|
| +
|
| +class ChromiumHandler(webapp2.RequestHandler):
|
| +
|
| + @staticmethod
|
| + def _can_see_list(user, committer_list):
|
| + """Returns True if the user is allowed to see the list."""
|
| + if not user:
|
| + return False
|
| + if users.is_current_user_admin():
|
| + return True
|
| + email = user.email()
|
| + if email in committer_list:
|
| + return True
|
| + if (email.endswith('@google.com') and
|
| + email[:-11] + '@chromium.org' in committer_list):
|
| + return True
|
| + return False
|
| +
|
| + def get(self):
|
| + """Displays the list of chromium committers in plain text."""
|
| + self.response.headers['Content-Type'] = 'text/plain'
|
| +
|
| + committer_list = ndb.Key(model.EmailList, constants.LIST).get()
|
| + emails = committer_list.emails if committer_list else []
|
| +
|
| + authenticated = False
|
| + try:
|
| + auth_util.CheckRequest(self.request)
|
| + authenticated = True
|
| + except:
|
| + user = users.get_current_user()
|
| + authenticated = self._can_see_list(user, emails)
|
| +
|
| + if authenticated:
|
| + self.response.write('\n'.join(sorted(emails)))
|
| + else:
|
| + self.response.status = 403
|
| + self.response.write('403: Forbidden')
|
| +
|
| +
|
| +class MappingHandler(webapp2.RequestHandler):
|
| +
|
| + def get(self):
|
| + """Displays the mapping of chromium to googler email addresses."""
|
| + self.response.headers['Content-Type'] = 'text/plain'
|
| + self.response.out.write('Not yet implemented. Sorry!')
|
| +
|
| +
|
| +class UpdateHandler(webapp2.RequestHandler):
|
| + def post(self):
|
| + """Updates the list of committers from the POST data recieved."""
|
| + auth_util.CheckRequest(self.request)
|
| + emails = request.get('committers')
|
| + committer_list = model.EmailList(id=constants.LIST, emails=emails)
|
| + committer_list.put()
|
| +
|
| +
|
| +app = webapp2.WSGIApplication([
|
| + ('/chromium', ChromiumHandler),
|
| + ('/mapping', MappingHandler),
|
| + ('/update', UpdateHandler),
|
| + ], debug=True)
|
|
|