userlisting: Document endpoints.

This commit is contained in:
Andre D
2014-04-25 16:32:57 -04:00
committed by Keith Mitchell
parent c21dc313e7
commit b627f69a2a
2 changed files with 37 additions and 12 deletions

View File

@@ -183,7 +183,7 @@ def make_map():
action='timereddit_redirect')
mc('/prefs/:where', controller='userlistlisting',
action='listing', requirements=dict(where='blocked|friends'))
action='user_prefs', requirements=dict(where='blocked|friends'))
mc('/prefs/:location', controller='forms', action='prefs',
location='options')

View File

@@ -1313,12 +1313,46 @@ class UserListListingController(ListingController):
content = self.listing_obj
return content
@require_oauth2_scope("read")
@base_listing
@listing_api_doc(section=api_section.account,
uri='/prefs/{where}',
uri_variants=['/prefs/' + where for where in [
'blocked', 'friends']])
def GET_user_prefs(self, where, **kw):
self.where = where
self.listing_cls = None
self.editable = True
self.paginated = False
self.jump_to_val = None
self.show_not_found = False
self.show_jump_to = False
if where == 'friends':
self.listing_cls = FriendListing
elif where == 'blocked':
self.listing_cls = EnemyListing
self.show_not_found = True
else:
abort(404)
kw['num'] = 0
check_cheating('site')
return self.build_listing(**kw)
@require_oauth2_scope("read")
@validate(user=VAccountByName('user'))
@base_listing
@listing_api_doc(section=api_section.subreddits,
uses_site=True,
uri='/about/{where}',
uri_variants=['/about/' + where for where in [
'banned', 'wikibanned', 'contributors',
'wikicontributors', 'moderators']])
def GET_listing(self, where, user=None, **kw):
allow_on_fake_sr = ["blocked", "friends"]
if isinstance(c.site, FakeSubreddit) and not where in allow_on_fake_sr:
if isinstance(c.site, FakeSubreddit):
return self.abort404()
self.where = where
@@ -1368,15 +1402,6 @@ class UserListListingController(ListingController):
self.listing_cls = ModListing
self.paginated = False
elif where == 'friends':
self.listing_cls = FriendListing
self.paginated = False
elif where == 'blocked':
self.listing_cls = EnemyListing
self.paginated = False
self.show_not_found = True
if not self.listing_cls:
abort(404)