Add '/subreddits/default.json' endpoint

For loading the default subreddits.
This commit is contained in:
Jack Lawson
2015-05-13 12:46:55 -07:00
parent 11ecbe6092
commit a8e0b303fe
2 changed files with 8 additions and 1 deletions

View File

@@ -86,7 +86,7 @@ def make_map():
mc('/subreddits/search', controller='front', action='search_reddits')
mc('/subreddits/login', controller='forms', action='login')
mc('/subreddits/:where', controller='reddits', action='listing',
where='popular', requirements=dict(where="popular|new|banned|employee|gold"))
where='popular', requirements=dict(where="popular|new|banned|employee|gold|default"))
# If no subreddit is specified, might as well show a list of 'em.
mc('/r', controller='redirect', action='redirect', dest='/subreddits')

View File

@@ -1297,6 +1297,12 @@ class RedditsController(ListingController):
stale=True,
)
reddits._sort = desc('_downs')
elif self.where == 'default':
return [
sr._fullname
for sr in Subreddit.default_subreddits(ids=False)
if sr.author_id is not -1
]
else:
reddits = Subreddit._query( write_cache = True,
read_cache = True,
@@ -1321,6 +1327,7 @@ class RedditsController(ListingController):
'/subreddits/new',
'/subreddits/employee',
'/subreddits/gold',
'/subreddits/default',
])
def GET_listing(self, where, **env):
"""Get all subreddits.