diff --git a/r2/r2/lib/pages/pages.py b/r2/r2/lib/pages/pages.py index cdbab52f6..b8a27d259 100644 --- a/r2/r2/lib/pages/pages.py +++ b/r2/r2/lib/pages/pages.py @@ -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): diff --git a/r2/r2/templates/subredditinfobar.html b/r2/r2/templates/subredditinfobar.html index 148a179f5..7c71b3efd 100644 --- a/r2/r2/templates/subredditinfobar.html +++ b/r2/r2/templates/subredditinfobar.html @@ -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: -
- %endif +<%def name="flair_control(flair_user)"> + %if flair_user: + %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}