From fbda2ed167e387049f01eef874b78ffddf4bc1f6 Mon Sep 17 00:00:00 2001 From: Brian Simpson Date: Fri, 29 Jul 2011 16:21:12 -0700 Subject: [PATCH] Make the edit box appear when editing a blank self post. --- r2/r2/lib/filters.py | 3 +++ r2/r2/lib/pages/pages.py | 15 ++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/r2/r2/lib/filters.py b/r2/r2/lib/filters.py index 73920846b..08a2dd29a 100644 --- a/r2/r2/lib/filters.py +++ b/r2/r2/lib/filters.py @@ -84,6 +84,9 @@ except ImportError: class _Unsafe(unicode): pass def _force_unicode(text): + if text == None: + return u'' + try: text = unicode(text, 'utf-8') except UnicodeDecodeError: diff --git a/r2/r2/lib/pages/pages.py b/r2/r2/lib/pages/pages.py index 39d3aaffc..cdbab52f6 100644 --- a/r2/r2/lib/pages/pages.py +++ b/r2/r2/lib/pages/pages.py @@ -2811,19 +2811,20 @@ def make_link_child(item): if media_embed: link_child = MediaChild(item, media_embed, load = True) - # if the item has selftext, add a selftext child - elif item.selftext: + # if the item is_self, add a selftext child + elif item.is_self: + if not item.selftext: item.selftext = u'' + expand = getattr(item, 'expand_children', False) - link_child = SelfTextChild(item, expand = expand, - nofollow = item.nofollow) - #draw the edit button if the contents are pre-expanded + editable = (expand and item.author == c.user and - not item._deleted) + not item._deleted) + link_child = SelfTextChild(item, expand = expand, + nofollow = item.nofollow) return link_child, editable - class MediaChild(LinkChild): """renders when the user hits the expando button to expand media objects, like embedded videos"""