/dev/api: Show /api/flairselector docs

This commit is contained in:
Keith Mitchell
2014-02-13 15:53:01 -08:00
parent 667a863faf
commit 0e647695d3
2 changed files with 17 additions and 0 deletions

View File

@@ -3209,7 +3209,18 @@ class ApiController(RedditController, OAuth2ResourceController):
@validate(VUser(),
user = VFlairAccount('name'),
link = VFlairLink('link'))
@api_doc(api_section.flair, uses_site=True)
def POST_flairselector(self, user, link):
"""Return information about a users's flair options.
If `link` is given, return link flair options.
Otherwise, return user flair options for this subreddit.
The logged in user's flair is also returned.
Subreddit moderators may give a user by `name` to instead
retrieve that user's flair.
"""
if link:
if hasattr(c.site, '_id') and c.site._id == link.sr_id:
site = c.site

View File

@@ -2149,6 +2149,9 @@ class VFlairAccount(VRequired):
or self._lookup(name, True)
or self.error())
def param_docs(self):
return {self.param: _("a user by name")}
class VFlairLink(VRequired):
def __init__(self, item, *a, **kw):
VRequired.__init__(self, item, errors.BAD_FLAIR_TARGET, *a, **kw)
@@ -2161,6 +2164,9 @@ class VFlairLink(VRequired):
except NotFound:
return self.error()
def param_docs(self):
return {self.param: _("a [fullname](#fullname) of a link")}
class VFlairCss(VCssName):
def __init__(self, param, max_css_classes=10, **kw):
self.max_css_classes = max_css_classes