Add before/after support for Details.

This commit is contained in:
bsimpson63
2012-07-25 16:43:15 -04:00
parent a552bc858d
commit 3712464798
3 changed files with 23 additions and 7 deletions

View File

@@ -116,8 +116,11 @@ class FrontController(RedditController):
@prevent_framing_and_css()
@validate(VAdmin(),
thing = VByName('article'),
oldid36 = nop('article'))
def GET_details(self, thing, oldid36):
oldid36 = nop('article'),
after=nop('after'),
before=nop('before'),
count=VCount('count'))
def GET_details(self, thing, oldid36, after, before, count):
"""The (now deprecated) details page. Content on this page
has been subsubmed by the presence of the LinkInfoBar on the
rightbox, so it is only useful for Admin-only wizardry."""
@@ -128,7 +131,14 @@ class FrontController(RedditController):
except (NotFound, ValueError):
abort(404)
return DetailsPage(thing=thing, expand_children=False).render()
kw = {'count': count}
if before:
kw['after'] = before
kw['reverse'] = True
else:
kw['after'] = after
kw['reverse'] = False
return DetailsPage(thing=thing, expand_children=False, **kw).render()
def GET_selfserviceoatmeal(self):
return BoringPage(_("self service help"),

View File

@@ -32,8 +32,8 @@ class AdminSidebar(Templated):
class Details(Templated):
def __init__(self, link):
Templated.__init__(self)
def __init__(self, link, *a, **kw):
Templated.__init__(self, *a, **kw)
self.link = link

View File

@@ -2914,11 +2914,17 @@ class DetailsPage(LinkInfoPage):
def __init__(self, thing, *args, **kwargs):
from admin_pages import Details
after = kwargs.pop('after', None)
reverse = kwargs.pop('reverse', False)
count = kwargs.pop('count', None)
if isinstance(thing, (Link, Comment)):
details = Details(thing, after=after, reverse=reverse, count=count)
if isinstance(thing, Link):
link = thing
comment = None
content = Details(thing=thing)
content = details
elif isinstance(thing, Comment):
comment = thing
link = Link._byID(comment.link_id)
@@ -2927,7 +2933,7 @@ class DetailsPage(LinkInfoPage):
content.append(LinkCommentSep())
content.append(CommentPane(link, CommentSortMenu.operator('new'),
comment, None, 1))
content.append(Details(thing=thing))
content.append(details)
kwargs['content'] = content
LinkInfoPage.__init__(self, link, comment, *args, **kwargs)