Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(437)

Side by Side Diff: status.py

Issue 108823002: chromium-status: improve status field editing (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/chromium-status
Patch Set: replace newlines with spaces Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « static/js/main/main.js ('k') | templates/main.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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', ' ')
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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 else: 414 else:
408 put_status(Status(message=new_message, username=self.user.email())) 415 put_status(Status(message=new_message, username=self.user.email()))
409 self.redirect("/") 416 self.redirect("/")
410 417
411 418
412 def bootstrap(): 419 def bootstrap():
413 # Guarantee that at least one instance exists. 420 # Guarantee that at least one instance exists.
414 if db.GqlQuery('SELECT __key__ FROM Status').get() is None: 421 if db.GqlQuery('SELECT __key__ FROM Status').get() is None:
415 Status(username='none', message='welcome to status').put() 422 Status(username='none', message='welcome to status').put()
416 LinkableText.bootstrap(BasePage.APP_NAME) 423 LinkableText.bootstrap(BasePage.APP_NAME)
OLDNEW
« no previous file with comments | « static/js/main/main.js ('k') | templates/main.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698