From dbdf637d9fe66f99c290f041e3794e23a00bc06d Mon Sep 17 00:00:00 2001 From: Neil Williams Date: Mon, 21 May 2012 17:03:36 -0700 Subject: [PATCH] Seperate "description" and "sidebar" for subreddits. --- r2/r2/controllers/api.py | 4 +++- r2/r2/lib/jsontemplates.py | 1 + r2/r2/models/modaction.py | 3 ++- r2/r2/models/subreddit.py | 7 ++++++- r2/r2/templates/createsubreddit.html | 11 ++++++++++- r2/r2/templates/subreddit.compact | 6 +++--- r2/r2/templates/subreddit.html | 4 ++-- r2/r2/templates/subreddit.xml | 4 ++-- r2/r2/templates/subredditinfobar.html | 2 +- 9 files changed, 30 insertions(+), 12 deletions(-) diff --git a/r2/r2/controllers/api.py b/r2/r2/controllers/api.py index 7557dccff..9f52475d3 100755 --- a/r2/r2/controllers/api.py +++ b/r2/r2/controllers/api.py @@ -1368,6 +1368,7 @@ class ApiController(RedditController): title = VLength("title", max_length = 100), header_title = VLength("header-title", max_length = 500), domain = VCnameDomain("domain"), + public_description = VMarkdown("public_description", max_length = 500), description = VMarkdown("description", max_length = 5120), lang = VLang("lang"), over_18 = VBoolean('over_18'), @@ -1393,7 +1394,7 @@ class ApiController(RedditController): if k in ('name', 'title', 'domain', 'description', 'over_18', 'show_media', 'show_cname_sidebar', 'type', 'link_type', 'lang', "css_on_cname", "header_title", - 'allow_top')) + 'allow_top', 'public_description')) #if a user is banned, return rate-limit errors if c.user._spam: @@ -1419,6 +1420,7 @@ class ApiController(RedditController): elif form.has_errors('domain', errors.BAD_CNAME, errors.USED_CNAME): form.find('#example_domain').hide() elif (form.has_errors(('type', 'link_type'), errors.INVALID_OPTION) or + form.has_errors('public_description', errors.TOO_LONG) or form.has_errors('description', errors.TOO_LONG)): pass diff --git a/r2/r2/lib/jsontemplates.py b/r2/r2/lib/jsontemplates.py index 808d5cc41..4b75396c4 100755 --- a/r2/r2/lib/jsontemplates.py +++ b/r2/r2/lib/jsontemplates.py @@ -212,6 +212,7 @@ class SubredditJsonTemplate(ThingJsonTemplate): url = "path", over18 = "over_18", description = "description", + public_description = "public_description", display_name = "name", header_img = "header", header_size = "header_size", diff --git a/r2/r2/models/modaction.py b/r2/r2/models/modaction.py index 06b357da6..4410338a1 100644 --- a/r2/r2/models/modaction.py +++ b/r2/r2/models/modaction.py @@ -69,7 +69,8 @@ class ModAction(tdb_cassandra.UuidThing, Printable): 'remove_self': _('removed self'), # editsettings 'title': _('title'), - 'description': _('description'), + 'public_description': _('description'), + 'description': _('sidebar'), 'lang': _('language'), 'type': _('type'), 'link_type': _('link type'), diff --git a/r2/r2/models/subreddit.py b/r2/r2/models/subreddit.py index 7b07c8f1e..be3d57af5 100644 --- a/r2/r2/models/subreddit.py +++ b/r2/r2/models/subreddit.py @@ -57,6 +57,7 @@ class Subreddit(Thing, Printable): header_size = None, header_title = "", allow_top = False, # overridden in "_new" + public_description = '', description = '', images = {}, reported = 0, @@ -388,7 +389,11 @@ class Subreddit(Thing, Printable): #will seem less horrible when add_props is in pages.py from r2.lib.pages import UserText - item.usertext = UserText(item, item.description, target=target) + item.description_usertext = UserText(item, item.description, target=target) + if item.public_description or item.description: + item.public_description_usertext = UserText(item, item.public_description or item.description, target=target) + else: + item.public_description_usertext = None Printable.add_props(user, wrapped) diff --git a/r2/r2/templates/createsubreddit.html b/r2/r2/templates/createsubreddit.html index 3f89e1d86..a82ee6820 100644 --- a/r2/r2/templates/createsubreddit.html +++ b/r2/r2/templates/createsubreddit.html @@ -66,7 +66,16 @@ <%utils:line_field title="${_('description')}" css_class="usertext" - description="${_('500 characters max. Make them count.')}"> + description="${_('publicly describe your subreddit for all to see. 500 characters max.')}"> + %if thing.site and thing.site.public_description: + ${UserText(None, text=thing.site.public_description or "", editable=True, creating=True, name="public_description", have_form=False)} + %else: + ${UserText(None, text="", creating=True, name="public_description", have_form=False)} + %endif + + + <%utils:line_field title="${_('sidebar')}" css_class="usertext" + description="${_('shown in the sidebar of your subreddit. 5120 characters max.')}"> %if thing.site and thing.site.description: ${UserText(None, text = thing.site.description or "", editable = True, creating = True, name="description", have_form = False)} %else: diff --git a/r2/r2/templates/subreddit.compact b/r2/r2/templates/subreddit.compact index 10f3e6b6a..5b70cbab1 100644 --- a/r2/r2/templates/subreddit.compact +++ b/r2/r2/templates/subreddit.compact @@ -43,7 +43,7 @@ reverse = thing.subscriber)}
- %if thing.description: + %if thing.public_description or thing.description: @@ -55,10 +55,10 @@

${tagline()}

- %if thing.description: + %if thing.public_description_usertext: %endif diff --git a/r2/r2/templates/subreddit.html b/r2/r2/templates/subreddit.html index ee0ecbf3d..b4a3e2dc3 100644 --- a/r2/r2/templates/subreddit.html +++ b/r2/r2/templates/subreddit.html @@ -42,9 +42,9 @@ ${self.admintagline()} %endif

-%if thing.description: +%if thing.public_description_usertext:
- ${thing.usertext} + ${thing.public_description_usertext}
%endif

diff --git a/r2/r2/templates/subreddit.xml b/r2/r2/templates/subreddit.xml index fa7578d4d..26df978d8 100644 --- a/r2/r2/templates/subreddit.xml +++ b/r2/r2/templates/subreddit.xml @@ -26,8 +26,8 @@ ${thing.path} ${thing._date.isoformat()} - %if thing.description: - ${thing.description} + %if thing.public_description: + ${thing.public_description} %endif <a href="${thing.path}">[link]</a> diff --git a/r2/r2/templates/subredditinfobar.html b/r2/r2/templates/subredditinfobar.html index 4194a43c6..187d56e17 100644 --- a/r2/r2/templates/subredditinfobar.html +++ b/r2/r2/templates/subredditinfobar.html @@ -64,7 +64,7 @@ %endif %if thing.sr.description: - ${thing.sr.usertext} + ${thing.sr.description_usertext} %endif