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

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') | no next file with comments »
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,81 @@
+# 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 base64
+import json
+import os
+
+import jinja2
+import webapp2
+
+from google.appengine.api import users
+from google.appengine.ext import ndb
+
+import auth_util
+import constants
+import hmac_util
+import model
+
+
+TEMPLATES_PATH = os.path.join(os.path.dirname(__file__), 'templates')
+JINJA2_ENVIRONMENT = jinja2.Environment(
+ loader=jinja2.FileSystemLoader(TEMPLATES_PATH),
+ autoescape=True,
+ extensions=['jinja2.ext.autoescape'])
+
+
+class MainPageHandler(webapp2.RequestHandler):
+
+ def get(self):
+ """Displays the homepage, with a login url."""
+ template = JINJA2_ENVIRONMENT.get_template('index.html')
+ template_values = {'login_url': users.create_login_url(dest_url='/')}
+ page = template.render(template_values)
+ self.response.write(page)
+
+
+class ChromiumHandler(webapp2.RequestHandler):
+
+ @auth_util.CheckUserAuth
+ @hmac_util.CheckHmacAuth
+ @auth_util.RequireAuth
+ def get(self):
+ """Displays the list of chromium committers in plain text."""
+ committer_list = ndb.Key(model.EmailList, constants.LIST).get()
+ emails = committer_list.emails if committer_list else []
+ self.response.headers['Content-Type'] = 'text/plain'
+ self.response.write('\n'.join(sorted(emails)))
+
+
+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):
+
+ @hmac_util.CheckHmacAuth
+ @auth_util.RequireAuth
+ def post(self):
+ """Updates the list of committers from the POST data recieved."""
+ emails = base64.b64decode(self.request.get('committers'))
+ email_list = json.loads(emails)
+ committer_list = model.EmailList(id=constants.LIST, emails=email_list)
+ committer_list.put()
+
+
+app = webapp2.WSGIApplication([
+ ('/', MainPageHandler),
+ ('/chromium', ChromiumHandler),
+ ('/mapping', MappingHandler),
+ ('/update', UpdateHandler),
+ ], debug=True)
« no previous file with comments | « no previous file | chromium-committers/app.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698