mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-26 15:28:37 -05:00
Add JSON api access to various user lists.
This commit is contained in:
@@ -43,7 +43,10 @@ api('morechildren', MoreCommentJsonTemplate)
|
||||
api('reddit', RedditJsonTemplate)
|
||||
api('panestack', PanestackJsonTemplate)
|
||||
api('listing', ListingJsonTemplate)
|
||||
api('usertableitem', UserItemJsonTemplate)
|
||||
api('modlist', UserListJsonTemplate)
|
||||
api('contributorlist', UserListJsonTemplate)
|
||||
api('bannedlist', UserListJsonTemplate)
|
||||
api('friendlist', UserListJsonTemplate)
|
||||
api('account', AccountJsonTemplate)
|
||||
|
||||
api('organiclisting', OrganicListingJsonTemplate)
|
||||
@@ -52,3 +55,5 @@ api('takedownpane', TakedownJsonTemplate)
|
||||
|
||||
api('flairlist', FlairListJsonTemplate)
|
||||
api('flaircsv', FlairCsvJsonTemplate)
|
||||
|
||||
tpm.add_handler('usertableitem', 'api-html', UserItemHTMLJsonTemplate())
|
||||
|
||||
@@ -91,7 +91,7 @@ class TableRowTemplate(JsonTemplate):
|
||||
css_class = self.css_class(thing),
|
||||
cells = self.cells(thing)))
|
||||
|
||||
class UserItemJsonTemplate(TableRowTemplate):
|
||||
class UserItemHTMLJsonTemplate(TableRowTemplate):
|
||||
def cells(self, thing):
|
||||
cells = []
|
||||
for cell in thing.cells:
|
||||
@@ -468,6 +468,23 @@ class ListingJsonTemplate(ThingJsonTemplate):
|
||||
def kind(self, wrapped):
|
||||
return "Listing"
|
||||
|
||||
class UserListJsonTemplate(ThingJsonTemplate):
|
||||
_data_attrs_ = dict(children = "users")
|
||||
|
||||
def thing_attr(self, thing, attr):
|
||||
if attr == "users":
|
||||
res = []
|
||||
for a in thing.users:
|
||||
res.append(a.user.name)
|
||||
return res
|
||||
return ThingJsonTemplate.thing_attr(self, thing, attr)
|
||||
|
||||
def rendered_data(self, thing):
|
||||
return self.thing_attr(thing, "users")
|
||||
|
||||
def kind(self, wrapped):
|
||||
return "UserList"
|
||||
|
||||
class OrganicListingJsonTemplate(ListingJsonTemplate):
|
||||
def kind(self, wrapped):
|
||||
return "OrganicListing"
|
||||
|
||||
Reference in New Issue
Block a user