OLD | NEW |
1 # coding=utf-8 | 1 # coding=utf-8 |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Status management pages.""" | 6 """Status management pages.""" |
7 | 7 |
8 import datetime | 8 import datetime |
9 import json | 9 import json |
10 import re | 10 import re |
11 | 11 |
12 from google.appengine.api import memcache | 12 from google.appengine.api import memcache |
13 from google.appengine.ext import db | 13 from google.appengine.ext import db |
14 | 14 |
15 from base_page import BasePage | 15 from base_page import BasePage |
16 import utils | 16 import utils |
17 | 17 |
18 | 18 |
19 ALLOWED_ORIGINS = [ | 19 ALLOWED_ORIGINS = [ |
20 'https://gerrit-int.chromium.org', | 20 'https://gerrit-int.chromium.org', |
21 'https://gerrit.chromium.org', | 21 'https://gerrit.chromium.org', |
| 22 'https://chrome-internal-review.googlesource.com', |
| 23 'https://chromium-review.googlesource.com', |
22 ] | 24 ] |
23 | 25 |
24 | 26 |
25 class Status(db.Model): | 27 class Status(db.Model): |
26 """Description for the status table.""" | 28 """Description for the status table.""" |
27 # The username who added this status. | 29 # The username who added this status. |
28 username = db.StringProperty(required=True) | 30 username = db.StringProperty(required=True) |
29 # The date when the status got added. | 31 # The date when the status got added. |
30 date = db.DateTimeProperty(auto_now_add=True) | 32 date = db.DateTimeProperty(auto_now_add=True) |
31 # The message. It can contain html code. | 33 # The message. It can contain html code. |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 """Displays the /current page.""" | 158 """Displays the /current page.""" |
157 | 159 |
158 def get(self): | 160 def get(self): |
159 # Show login link on current status bar when login is required. | 161 # Show login link on current status bar when login is required. |
160 out_format = self.request.get('format', 'html') | 162 out_format = self.request.get('format', 'html') |
161 if out_format == 'html' and not self.read_access and not self.user: | 163 if out_format == 'html' and not self.read_access and not self.user: |
162 template_values = self.InitializeTemplate(self.APP_NAME + ' Tree Status') | 164 template_values = self.InitializeTemplate(self.APP_NAME + ' Tree Status') |
163 template_values['show_login'] = True | 165 template_values['show_login'] = True |
164 self.DisplayTemplate('current.html', template_values, use_cache=True) | 166 self.DisplayTemplate('current.html', template_values, use_cache=True) |
165 else: | 167 else: |
166 self._handle() | 168 self._handle() |
167 | 169 |
168 @utils.requires_read_access | 170 @utils.requires_read_access |
169 def _handle(self): | 171 def _handle(self): |
170 """Displays the current message in various formats.""" | 172 """Displays the current message in various formats.""" |
171 out_format = self.request.get('format', 'html') | 173 out_format = self.request.get('format', 'html') |
172 status = get_status() | 174 status = get_status() |
173 if out_format == 'raw': | 175 if out_format == 'raw': |
174 self.response.headers['Content-Type'] = 'text/plain' | 176 self.response.headers['Content-Type'] = 'text/plain' |
175 self.response.out.write(status.message) | 177 self.response.out.write(status.message) |
176 elif out_format == 'json': | 178 elif out_format == 'json': |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 return self._handle(error_message, last_message) | 291 return self._handle(error_message, last_message) |
290 else: | 292 else: |
291 put_status(Status(message=new_message, username=self.user.email())) | 293 put_status(Status(message=new_message, username=self.user.email())) |
292 self.redirect("/") | 294 self.redirect("/") |
293 | 295 |
294 | 296 |
295 def bootstrap(): | 297 def bootstrap(): |
296 # Guarantee that at least one instance exists. | 298 # Guarantee that at least one instance exists. |
297 if db.GqlQuery('SELECT __key__ FROM Status').get() is None: | 299 if db.GqlQuery('SELECT __key__ FROM Status').get() is None: |
298 Status(username='none', message='welcome to status').put() | 300 Status(username='none', message='welcome to status').put() |
OLD | NEW |