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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chromium-committers/app.yaml » ('j') | chromium-committers/auth_util.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
« 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