| 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 return LinkableText(self.username) | 142 return LinkableText(self.username) |
| 143 | 143 |
| 144 @property | 144 @property |
| 145 def message_links(self): | 145 def message_links(self): |
| 146 return LinkableText(self.message) | 146 return LinkableText(self.message) |
| 147 | 147 |
| 148 @property | 148 @property |
| 149 def general_state(self): | 149 def general_state(self): |
| 150 """Returns a string representing the state that the status message | 150 """Returns a string representing the state that the status message |
| 151 describes. | 151 describes. |
| 152 |
| 153 Note: Keep in sync with main.html help text. |
| 152 """ | 154 """ |
| 153 message = self.message | 155 message = self.message |
| 154 closed = re.search('close', message, re.IGNORECASE) | 156 closed = re.search('close', message, re.IGNORECASE) |
| 155 if closed and re.search('maint', message, re.IGNORECASE): | 157 if closed and re.search('maint', message, re.IGNORECASE): |
| 156 return 'maintenance' | 158 return 'maintenance' |
| 157 if re.search('throt', message, re.IGNORECASE): | 159 if re.search('throt', message, re.IGNORECASE): |
| 158 return 'throttled' | 160 return 'throttled' |
| 159 if closed: | 161 if closed: |
| 160 return 'closed' | 162 return 'closed' |
| 161 return 'open' | 163 return 'open' |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 else: | 406 else: |
| 405 put_status(Status(message=new_message, username=self.user.email())) | 407 put_status(Status(message=new_message, username=self.user.email())) |
| 406 self.redirect("/") | 408 self.redirect("/") |
| 407 | 409 |
| 408 | 410 |
| 409 def bootstrap(): | 411 def bootstrap(): |
| 410 # Guarantee that at least one instance exists. | 412 # Guarantee that at least one instance exists. |
| 411 if db.GqlQuery('SELECT __key__ FROM Status').get() is None: | 413 if db.GqlQuery('SELECT __key__ FROM Status').get() is None: |
| 412 Status(username='none', message='welcome to status').put() | 414 Status(username='none', message='welcome to status').put() |
| 413 LinkableText.bootstrap(BasePage.APP_NAME) | 415 LinkableText.bootstrap(BasePage.APP_NAME) |
| OLD | NEW |