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

Side by Side Diff: Tools/GardeningServer/internal_alerts.py

Issue 633983002: Implemented retrieval of alerts history (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Lowered MAX_LIMIT_PER_PAGE because it was generating too large response for AE Created 6 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
« no previous file with comments | « Tools/GardeningServer/app.yaml ('k') | Tools/GardeningServer/internal_alerts_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import datetime 5 import datetime
6 import alerts 6 import alerts
7 import json 7 import json
8 import webapp2 8 import webapp2
9 9
10 from google.appengine.api import users 10 from google.appengine.api import users
11 11
12 12
13 class InternalAlertsHandler(alerts.AlertsHandler): 13 class InternalAlertsHandler(alerts.AlertsHandler):
14 MEMCACHE_INTERNAL_ALERTS_KEY = 'internal-alerts' 14 INTERNAL_ALERTS_TYPE = 'internal-alerts'
15 15
16 # Has no 'request' member. 16 # Has no 'request' member.
17 # Has no 'response' member. 17 # Has no 'response' member.
18 # Use of super on an old style class. 18 # Use of super on an old style class.
19 # pylint: disable=E1002,E1101 19 # pylint: disable=E1002,E1101
20 def get(self): 20 def get(self):
21 # Require users to be logged to see builder alerts from private/internal 21 # Require users to be logged to see builder alerts from private/internal
22 # trees. 22 # trees.
23 user = users.get_current_user() 23 user = users.get_current_user()
24 if not user: 24 if not user:
25 alerts = {} 25 alerts = {}
26 alerts.update({ 26 alerts.update({
27 'date': datetime.datetime.utcnow(), 27 'date': datetime.datetime.utcnow(),
28 'redirect-url': users.create_login_url(self.request.uri)}) 28 'redirect-url': users.create_login_url(self.request.uri)})
29 uncompressed = super(InternalAlertsHandler, 29 uncompressed = super(InternalAlertsHandler,
30 self).generate_json_dump(alerts) 30 self).generate_json_dump(alerts)
31 super(InternalAlertsHandler, self).send_json_data(uncompressed) 31 super(InternalAlertsHandler, self).send_json_data(uncompressed)
32 return 32 return
33 33
34 email = user.email() 34 email = user.email()
35 if not email.endswith('@google.com'): 35 if not email.endswith('@google.com'):
36 self.response.set_status(403, 'invalid user') 36 self.response.set_status(403, 'invalid user')
37 return 37 return
38 38
39 super(InternalAlertsHandler, self).get_from_memcache( 39 super(InternalAlertsHandler, self).get_from_memcache(
40 InternalAlertsHandler.MEMCACHE_INTERNAL_ALERTS_KEY) 40 InternalAlertsHandler.INTERNAL_ALERTS_TYPE)
41 41
42 def post(self): 42 def post(self):
43 self.update_alerts(InternalAlertsHandler.MEMCACHE_INTERNAL_ALERTS_KEY) 43 self.update_alerts(InternalAlertsHandler.INTERNAL_ALERTS_TYPE)
44 44
45 45
46 app = webapp2.WSGIApplication([ 46 app = webapp2.WSGIApplication([
47 ('/internal-alerts', InternalAlertsHandler)]) 47 ('/internal-alerts', InternalAlertsHandler)])
OLDNEW
« no previous file with comments | « Tools/GardeningServer/app.yaml ('k') | Tools/GardeningServer/internal_alerts_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698