mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-25 14:58:27 -05:00
Fix users seeing other users' flair in sidebar.
Move some of the template logic into pages.py so the enflaired user becomes part of the cache key.
This commit is contained in:
@@ -485,14 +485,23 @@ class SubredditInfoBar(CachedTemplate):
|
||||
def __init__(self, site = None):
|
||||
site = site or c.site
|
||||
|
||||
#hackity hack. do i need to add all the others props?
|
||||
# hackity hack. do i need to add all the others props?
|
||||
self.sr = list(wrap_links(site))[0]
|
||||
|
||||
# we want to cache on the number of subscribers
|
||||
self.subscribers = self.sr._ups
|
||||
|
||||
#so the menus cache properly
|
||||
# so the menus cache properly
|
||||
self.path = request.path
|
||||
|
||||
# if user has flair, then it will be displayed in this bar
|
||||
self.flair_user = None
|
||||
if c.user_is_loggedin:
|
||||
wrapped_user = WrappedUser(c.user, subreddit=self.sr,
|
||||
force_show_flair=True)
|
||||
if wrapped_user.has_flair:
|
||||
self.flair_user = wrapped_user
|
||||
|
||||
CachedTemplate.__init__(self)
|
||||
|
||||
def nav(self):
|
||||
|
||||
@@ -36,24 +36,19 @@
|
||||
hidden_data = dict(id = thing.sr._fullname))}
|
||||
</%def>
|
||||
|
||||
<%def name="flair_control(user, sr)">
|
||||
%if c.user_is_loggedin:
|
||||
<%
|
||||
wrapped_user = WrappedUser(user, subreddit=sr, force_show_flair=True)
|
||||
%>
|
||||
%if wrapped_user.has_flair:
|
||||
<form class="toggle flairtoggle">
|
||||
<input id="flair_enabled" type="checkbox" name="flair_enabled"
|
||||
%if wrapped_user.flair_enabled:
|
||||
checked="checked"
|
||||
%endif
|
||||
>
|
||||
${_("Show my flair on this reddit. It looks like:")}
|
||||
<div class="tagline">
|
||||
${wrapped_user}
|
||||
</div>
|
||||
</form>
|
||||
%endif
|
||||
<%def name="flair_control(flair_user)">
|
||||
%if flair_user:
|
||||
<form class="toggle flairtoggle">
|
||||
<input id="flair_enabled" type="checkbox" name="flair_enabled"
|
||||
%if flair_user.flair_enabled:
|
||||
checked="checked"
|
||||
%endif
|
||||
>
|
||||
${_("Show my flair on this reddit. It looks like:")}
|
||||
<div class="tagline">
|
||||
${flair_user}
|
||||
</div>
|
||||
</form>
|
||||
%endif
|
||||
</%def>
|
||||
|
||||
@@ -80,7 +75,7 @@
|
||||
_("you are no longer an approved submitter"))}
|
||||
%endif
|
||||
|
||||
${flair_control(c.user, thing.sr)}
|
||||
${flair_control(thing.flair_user)}
|
||||
|
||||
%if thing.sr.description:
|
||||
${thing.sr.usertext}
|
||||
|
||||
Reference in New Issue
Block a user