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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 status = get_last_statuses(limit) | 253 status = get_last_statuses(limit) |
254 current_status = get_status() | 254 current_status = get_status() |
255 if not last_message: | 255 if not last_message: |
256 last_message = current_status.message | 256 last_message = current_status.message |
257 | 257 |
258 template_values = self.InitializeTemplate(self.APP_NAME + ' Tree Status') | 258 template_values = self.InitializeTemplate(self.APP_NAME + ' Tree Status') |
259 template_values['status'] = status | 259 template_values['status'] = status |
260 template_values['message'] = last_message | 260 template_values['message'] = last_message |
261 template_values['last_status_key'] = current_status.key() | 261 template_values['last_status_key'] = current_status.key() |
262 template_values['error_message'] = error_message | 262 template_values['error_message'] = error_message |
| 263 template_values['limit'] = limit |
263 self.DisplayTemplate('main.html', template_values) | 264 self.DisplayTemplate('main.html', template_values) |
264 | 265 |
265 @utils.requires_login | 266 @utils.requires_login |
266 @utils.requires_write_access | 267 @utils.requires_write_access |
267 def post(self): | 268 def post(self): |
268 """Adds a new message.""" | 269 """Adds a new message.""" |
269 # We pass these variables back into get(), prepare them. | 270 # We pass these variables back into get(), prepare them. |
270 last_message = '' | 271 last_message = '' |
271 error_message = '' | 272 error_message = '' |
272 | 273 |
(...skipping 15 matching lines...) Expand all Loading... |
288 return self._handle(error_message, last_message) | 289 return self._handle(error_message, last_message) |
289 else: | 290 else: |
290 put_status(Status(message=new_message, username=self.user.email())) | 291 put_status(Status(message=new_message, username=self.user.email())) |
291 self.redirect("/") | 292 self.redirect("/") |
292 | 293 |
293 | 294 |
294 def bootstrap(): | 295 def bootstrap(): |
295 # Guarantee that at least one instance exists. | 296 # Guarantee that at least one instance exists. |
296 if db.GqlQuery('SELECT __key__ FROM Status').get() is None: | 297 if db.GqlQuery('SELECT __key__ FROM Status').get() is None: |
297 Status(username='none', message='welcome to status').put() | 298 Status(username='none', message='welcome to status').put() |
OLD | NEW |