mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-27 07:48:16 -05:00
repair caching bug related to widget with votable buttons; add over18 parameter to subreddit json
This commit is contained in:
@@ -94,6 +94,8 @@ class ButtonsController(RedditController):
|
||||
css != 'http://www.wired.com/css/redditsocial.css'):
|
||||
css = None
|
||||
|
||||
if link:
|
||||
url = link.url
|
||||
wrapper = make_wrapper(Button if vote else ButtonNoBody,
|
||||
url = url,
|
||||
target = "_new" if newwindow else "_parent",
|
||||
|
||||
@@ -182,6 +182,7 @@ class SubredditJsonTemplate(ThingJsonTemplate):
|
||||
_data_attrs_ = ThingJsonTemplate.data_attrs(subscribers = "score",
|
||||
title = "title",
|
||||
url = "path",
|
||||
over18 = "over_18",
|
||||
description = "description")
|
||||
|
||||
class LinkJsonTemplate(ThingJsonTemplate):
|
||||
|
||||
@@ -109,16 +109,15 @@ class MessageButtons(PrintableButtons):
|
||||
|
||||
# formerly ListingController.builder_wrapper
|
||||
def default_thing_wrapper(**params):
|
||||
style = params.get('style', c.render_style)
|
||||
def _default_thing_wrapper(thing):
|
||||
w = Wrapped(thing)
|
||||
style = params.get('style', c.render_style)
|
||||
if isinstance(thing, Link):
|
||||
if thing.promoted:
|
||||
w.render_class = PromotedLink
|
||||
w.rowstyle = 'promoted link'
|
||||
elif style == 'htmllite':
|
||||
w.score_fmt = Score.points
|
||||
|
||||
return w
|
||||
params['parent_wrapper'] = _default_thing_wrapper
|
||||
return make_wrapper(**params)
|
||||
|
||||
@@ -410,8 +410,9 @@ class Wrapped(CachedTemplate):
|
||||
if self.cachable:
|
||||
for i, l in enumerate(self.lookups):
|
||||
if hasattr(l, "wrapped_cache_key"):
|
||||
# setattr will force a __dict__ entry
|
||||
setattr(self, "_lookup%d_cache_key" % i,
|
||||
# setattr will force a __dict__ entry, but only if the
|
||||
# param doesn't start with "_"
|
||||
setattr(self, "lookup%d_cache_key" % i,
|
||||
''.join(map(repr,
|
||||
l.wrapped_cache_key(self, style))))
|
||||
return CachedTemplate.cache_key(self, attr, style)
|
||||
|
||||
@@ -55,6 +55,7 @@ class Link(Thing, Printable):
|
||||
selftext = '',
|
||||
ip = '0.0.0.0')
|
||||
|
||||
|
||||
def __init__(self, *a, **kw):
|
||||
Thing.__init__(self, *a, **kw)
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ class Printable(object):
|
||||
can_ban = False
|
||||
deleted = False
|
||||
rowstyle = 'even'
|
||||
reported = False
|
||||
collapsed = False
|
||||
author = None
|
||||
margin = 0
|
||||
@@ -75,7 +74,7 @@ class Printable(object):
|
||||
|
||||
@staticmethod
|
||||
def wrapped_cache_key(wrapped, style):
|
||||
s = [wrapped._fullname, wrapped._spam]
|
||||
s = [wrapped._fullname, wrapped._spam, wrapped.reported]
|
||||
|
||||
if style == 'htmllite':
|
||||
s.extend([c.bgcolor, c.bordercolor,
|
||||
|
||||
Reference in New Issue
Block a user