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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
130 | 130 |
131 class Status(db.Model): | 131 class Status(db.Model): |
132 """Description for the status table.""" | 132 """Description for the status table.""" |
133 # The username who added this status. | 133 # The username who added this status. |
134 username = db.StringProperty(required=True) | 134 username = db.StringProperty(required=True) |
135 # The date when the status got added. | 135 # The date when the status got added. |
136 date = db.DateTimeProperty(auto_now_add=True) | 136 date = db.DateTimeProperty(auto_now_add=True) |
137 # The message. It can contain html code. | 137 # The message. It can contain html code. |
138 message = db.StringProperty(required=True) | 138 message = db.StringProperty(required=True) |
139 | 139 |
140 def __init__(self, *args, **kwargs): | |
141 # Normalize newlines otherwise the DB store barfs. We don't really want to | |
142 # make this field handle newlines as none of the places where we output the | |
143 # content is designed to handle it, nor the clients that consume us. | |
144 kwargs['message'] = kwargs.get('message', '').replace('\n', '') | |
agable
2014/03/25 17:17:19
newlines should be replaced with whitespace, not e
vapier
2014/03/25 18:01:13
Done.
| |
145 super(Status, self).__init__(*args, **kwargs) | |
146 | |
140 @property | 147 @property |
141 def username_links(self): | 148 def username_links(self): |
142 return LinkableText(self.username) | 149 return LinkableText(self.username) |
143 | 150 |
144 @property | 151 @property |
145 def message_links(self): | 152 def message_links(self): |
146 return LinkableText(self.message) | 153 return LinkableText(self.message) |
147 | 154 |
148 @property | 155 @property |
149 def general_state(self): | 156 def general_state(self): |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
406 else: | 413 else: |
407 put_status(Status(message=new_message, username=self.user.email())) | 414 put_status(Status(message=new_message, username=self.user.email())) |
408 self.redirect("/") | 415 self.redirect("/") |
409 | 416 |
410 | 417 |
411 def bootstrap(): | 418 def bootstrap(): |
412 # Guarantee that at least one instance exists. | 419 # Guarantee that at least one instance exists. |
413 if db.GqlQuery('SELECT __key__ FROM Status').get() is None: | 420 if db.GqlQuery('SELECT __key__ FROM Status').get() is None: |
414 Status(username='none', message='welcome to status').put() | 421 Status(username='none', message='welcome to status').put() |
415 LinkableText.bootstrap(BasePage.APP_NAME) | 422 LinkableText.bootstrap(BasePage.APP_NAME) |
OLD | NEW |