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 |
(...skipping 17 matching lines...) Expand all Loading... |
28 username = db.StringProperty(required=True) | 28 username = db.StringProperty(required=True) |
29 # The date when the status got added. | 29 # The date when the status got added. |
30 date = db.DateTimeProperty(auto_now_add=True) | 30 date = db.DateTimeProperty(auto_now_add=True) |
31 # The message. It can contain html code. | 31 # The message. It can contain html code. |
32 message = db.StringProperty(required=True) | 32 message = db.StringProperty(required=True) |
33 | 33 |
34 @property | 34 @property |
35 def general_state(self): | 35 def general_state(self): |
36 """Returns a string representing the state that the status message | 36 """Returns a string representing the state that the status message |
37 describes. | 37 describes. |
| 38 |
| 39 Note: Keep in sync with main.html help text. |
38 """ | 40 """ |
39 message = self.message | 41 message = self.message |
40 closed = re.search('close', message, re.IGNORECASE) | 42 closed = re.search('close', message, re.IGNORECASE) |
41 if closed and re.search('maint', message, re.IGNORECASE): | 43 if closed and re.search('maint', message, re.IGNORECASE): |
42 return 'maintenance' | 44 return 'maintenance' |
43 if re.search('throt', message, re.IGNORECASE): | 45 if re.search('throt', message, re.IGNORECASE): |
44 return 'throttled' | 46 return 'throttled' |
45 if closed: | 47 if closed: |
46 return 'closed' | 48 return 'closed' |
47 return 'open' | 49 return 'open' |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 return self._handle(error_message, last_message) | 290 return self._handle(error_message, last_message) |
289 else: | 291 else: |
290 put_status(Status(message=new_message, username=self.user.email())) | 292 put_status(Status(message=new_message, username=self.user.email())) |
291 self.redirect("/") | 293 self.redirect("/") |
292 | 294 |
293 | 295 |
294 def bootstrap(): | 296 def bootstrap(): |
295 # Guarantee that at least one instance exists. | 297 # Guarantee that at least one instance exists. |
296 if db.GqlQuery('SELECT __key__ FROM Status').get() is None: | 298 if db.GqlQuery('SELECT __key__ FROM Status').get() is None: |
297 Status(username='none', message='welcome to status').put() | 299 Status(username='none', message='welcome to status').put() |
OLD | NEW |