OLD | NEW |
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 calendar | 5 import calendar |
6 import datetime | 6 import datetime |
7 import json | 7 import json |
8 import logging | 8 import logging |
9 import webapp2 | 9 import webapp2 |
10 import zlib | 10 import zlib |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 alerts = self.parse_alerts(self.request.get('content')) | 105 alerts = self.parse_alerts(self.request.get('content')) |
106 if alerts: | 106 if alerts: |
107 self.post_to_memcache(alerts_type, alerts) | 107 self.post_to_memcache(alerts_type, alerts) |
108 self.post_to_history(alerts_type, alerts) | 108 self.post_to_history(alerts_type, alerts) |
109 | 109 |
110 def post(self): | 110 def post(self): |
111 self.update_alerts(AlertsHandler.ALERTS_TYPE) | 111 self.update_alerts(AlertsHandler.ALERTS_TYPE) |
112 | 112 |
113 | 113 |
114 class AlertsHistory(webapp2.RequestHandler): | 114 class AlertsHistory(webapp2.RequestHandler): |
115 MAX_LIMIT_PER_PAGE = 50 | 115 MAX_LIMIT_PER_PAGE = 5 |
116 | 116 |
117 def get(self): | 117 def get(self): |
118 alerts_query = AlertsJSON.query().order(-AlertsJSON.date) | 118 alerts_query = AlertsJSON.query().order(-AlertsJSON.date) |
119 result_json = {} | 119 result_json = {} |
120 | 120 |
121 user = users.get_current_user() | 121 user = users.get_current_user() |
122 if not user: | 122 if not user: |
123 result_json['redirect-url'] = users.create_login_url( | 123 result_json['redirect-url'] = users.create_login_url( |
124 self.request.uri) | 124 self.request.uri) |
125 | 125 |
(...skipping 22 matching lines...) Expand all Loading... |
148 }) | 148 }) |
149 | 149 |
150 self.response.headers['Content-Type'] = 'application/json' | 150 self.response.headers['Content-Type'] = 'application/json' |
151 self.response.out.write(json.dumps(result_json)) | 151 self.response.out.write(json.dumps(result_json)) |
152 | 152 |
153 | 153 |
154 app = webapp2.WSGIApplication([ | 154 app = webapp2.WSGIApplication([ |
155 ('/alerts', AlertsHandler), | 155 ('/alerts', AlertsHandler), |
156 ('/alerts-history', AlertsHistory) | 156 ('/alerts-history', AlertsHistory) |
157 ]) | 157 ]) |
OLD | NEW |