Skip to content

Commit

Permalink
Add before/after support for Details.
Browse files Browse the repository at this point in the history
  • Loading branch information
bsimpson63 committed Jul 25, 2012
1 parent a552bc8 commit 3712464
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
16 changes: 13 additions & 3 deletions r2/r2/controllers/front.py
Expand Up @@ -116,8 +116,11 @@ def GET_random(self):
@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."""
Expand All @@ -128,7 +131,14 @@ def GET_details(self, thing, oldid36):
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"),
Expand Down
4 changes: 2 additions & 2 deletions r2/r2/lib/pages/admin_pages.py
Expand Up @@ -32,8 +32,8 @@ def __init__(self, user):


class Details(Templated):
def __init__(self, link):
Templated.__init__(self)
def __init__(self, link, *a, **kw):
Templated.__init__(self, *a, **kw)
self.link = link


Expand Down
10 changes: 8 additions & 2 deletions r2/r2/lib/pages/pages.py
Expand Up @@ -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)
Expand All @@ -2927,7 +2933,7 @@ def __init__(self, thing, *args, **kwargs):
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)
Expand Down

0 comments on commit 3712464

Please sign in to comment.