Show link author and subreddit in user comment listings.

This commit is contained in:
Brian Simpson
2011-09-07 14:13:05 -07:00
parent 8b83dd9537
commit 03eaf83d9a
2 changed files with 27 additions and 2 deletions

View File

@@ -676,14 +676,19 @@ class Comment(Thing, Printable):
@classmethod
def add_props(cls, user, wrapped):
from r2.lib.template_helpers import add_attr
from r2.lib.template_helpers import add_attr, get_domain
from r2.lib import promote
from r2.lib.wrapped import CachedVariable
from r2.lib.pages import WrappedUser
#fetch parent links
links = Link._byID(set(l.link_id for l in wrapped), data = True,
return_dict = True, stale=True)
# fetch authors
authors = Account._byID(set(l.author_id for l in links.values()), data=True,
return_dict=True, stale=True)
#get srs for comments that don't have them (old comments)
for cm in wrapped:
if not hasattr(cm, 'sr_id'):
@@ -709,6 +714,8 @@ class Comment(Thing, Printable):
user_is_admin = c.user_is_admin
user_is_loggedin = c.user_is_loggedin
focal_comment = c.focal_comment
cname = c.cname
site = c.site
for item in wrapped:
# for caching:
@@ -763,6 +770,16 @@ class Comment(Thing, Printable):
if focal_comment == item._id36:
extra_css += " border"
if profilepage:
item.link_author = WrappedUser(authors[item.link.author_id])
item.subreddit_path = item.subreddit.path
if cname:
item.subreddit_path = ("http://" +
get_domain(cname = (site == item.subreddit),
subreddit = False))
if site != item.subreddit:
item.subreddit_path += item.subreddit.path
# don't collapse for admins, on profile pages, or if deleted
item.collapsed = False

View File

@@ -26,7 +26,7 @@
from r2.lib.pages import WrappedUser
%>
<%namespace file="utils.html" import="timestamp" />
<%namespace file="utils.html" import="plain_link, timestamp" />
<%inherit file="comment_skeleton.html"/>
#####################
@@ -54,6 +54,14 @@ ${parent.midcol(not thing.collapsed, cls = cls)}
${thing.link.url}
%endif
%endif
&#32;
${_("by")}
&#32;
${thing.link_author.render()}
${_("in")}
&#32;
${plain_link(thing.subreddit.name, thing.subreddit_path, sr_path = False,
cname = False, _class = "subreddit hover")}
%endif
</%def>