mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-23 22:08:11 -05:00
Move the saved links listing to the profile page hierarchy.
This commit is contained in:
@@ -156,10 +156,11 @@ def make_map(global_conf={}, app_conf={}):
|
||||
|
||||
mc('/', controller='hot', action='listing')
|
||||
|
||||
listing_controllers = "hot|saved|new|randomrising|comments"
|
||||
listing_controllers = "hot|new|randomrising|comments"
|
||||
|
||||
mc('/:controller', action='listing',
|
||||
requirements=dict(controller=listing_controllers))
|
||||
mc('/saved', controller='user', action='saved_redirect')
|
||||
|
||||
mc('/by_id/:names', controller='byId', action='listing')
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
################################################################################
|
||||
from listingcontroller import ListingController
|
||||
from listingcontroller import HotController
|
||||
from listingcontroller import SavedController
|
||||
from listingcontroller import NewController
|
||||
from listingcontroller import BrowseController
|
||||
from listingcontroller import MessageController
|
||||
|
||||
@@ -49,6 +49,7 @@ from admin import admin_profile_query
|
||||
|
||||
from pylons.i18n import _
|
||||
from pylons import Response
|
||||
from pylons.controllers.util import redirect_to
|
||||
|
||||
import random
|
||||
from functools import partial
|
||||
@@ -351,19 +352,6 @@ class HotController(FixListing, ListingController):
|
||||
self.infotext = request.get.get('deleted') and strings.user_deleted
|
||||
return ListingController.GET_listing(self, **env)
|
||||
|
||||
class SavedController(ListingController):
|
||||
where = 'saved'
|
||||
skip = False
|
||||
title_text = _('saved')
|
||||
|
||||
def query(self):
|
||||
return queries.get_saved(c.user)
|
||||
|
||||
@validate(VUser())
|
||||
@listing_api_doc(uri='/saved')
|
||||
def GET_listing(self, **env):
|
||||
return ListingController.GET_listing(self, **env)
|
||||
|
||||
class NewController(ListingController):
|
||||
where = 'new'
|
||||
title_text = _('newest submissions')
|
||||
@@ -527,6 +515,7 @@ class UserController(ListingController):
|
||||
'submitted': _("submitted by %(user)s"),
|
||||
'liked': _("liked by %(user)s"),
|
||||
'disliked': _("disliked by %(user)s"),
|
||||
'saved': _("saved by %(user)s"),
|
||||
'hidden': _("hidden by %(user)s")}
|
||||
title = titles.get(self.where, _('profile for %(user)s')) \
|
||||
% dict(user = self.vuser.name, site = c.site.name)
|
||||
@@ -548,6 +537,8 @@ class UserController(ListingController):
|
||||
return False
|
||||
if item.likes is not False and self.where == 'disliked':
|
||||
return False
|
||||
if self.where == 'saved' and not item.saved:
|
||||
return False
|
||||
return wouldkeep and (getattr(item, "promoted", None) is None and
|
||||
(self.where == "deleted" or
|
||||
not getattr(item, "deleted", False)))
|
||||
@@ -580,6 +571,9 @@ class UserController(ListingController):
|
||||
elif self.where == 'hidden':
|
||||
q = queries.get_hidden(self.vuser)
|
||||
|
||||
elif self.where == 'saved':
|
||||
q = queries.get_saved(self.vuser)
|
||||
|
||||
elif c.user_is_admin:
|
||||
q = admin_profile_query(self.vuser, self.where, desc('_date'))
|
||||
|
||||
@@ -594,7 +588,7 @@ class UserController(ListingController):
|
||||
@listing_api_doc(section=api_section.users, uri='/{username}/{where}',
|
||||
uri_variants=['/{username}/' + where for where in [
|
||||
'overview', 'submitted', 'commented',
|
||||
'liked', 'disliked', 'hidden']])
|
||||
'liked', 'disliked', 'hidden', 'saved']])
|
||||
def GET_listing(self, where, vuser, sort, time, **env):
|
||||
self.where = where
|
||||
self.sort = sort
|
||||
@@ -618,6 +612,11 @@ class UserController(ListingController):
|
||||
and not votes_visible(vuser)):
|
||||
return self.abort403()
|
||||
|
||||
if where == "saved" and not (c.user_is_loggedin and
|
||||
(c.user._id == vuser._id or
|
||||
c.user_is_admin)):
|
||||
self.abort403()
|
||||
|
||||
check_cheating('user')
|
||||
|
||||
self.vuser = vuser
|
||||
@@ -637,6 +636,11 @@ class UserController(ListingController):
|
||||
return self.abort404()
|
||||
return Reddit(content = Wrapped(vuser)).render()
|
||||
|
||||
def GET_saved_redirect(self):
|
||||
if not c.user_is_loggedin:
|
||||
abort(404)
|
||||
return redirect_to("/user/" + c.user.name + "/saved")
|
||||
|
||||
class MessageController(ListingController):
|
||||
show_nums = False
|
||||
render_cls = MessagePage
|
||||
|
||||
@@ -1227,6 +1227,9 @@ class ProfilePage(Reddit):
|
||||
NamedButton('disliked'),
|
||||
NamedButton('hidden')]
|
||||
|
||||
if c.user_is_loggedin and (c.user._id == self.user._id or
|
||||
c.user_is_admin):
|
||||
main_buttons += [NamedButton('saved')]
|
||||
|
||||
toolbar = [PageNameNav('nomenu', title = self.user.name),
|
||||
NavMenu(main_buttons, base_path = path, type="tabmenu")]
|
||||
|
||||
Reference in New Issue
Block a user