Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Move the saved links listing to the profile page hierarchy.

  • Loading branch information...
commit 6ab11b367c0d1628ed4e1cb83aefea7608fea202 1 parent c9c959d
@spladug spladug authored
View
3  r2/r2/config/routing.py
@@ -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')
View
1  r2/r2/controllers/__init__.py
@@ -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
View
32 r2/r2/controllers/listingcontroller.py
@@ -49,6 +49,7 @@
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 @@ def GET_listing(self, **env):
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 @@ def title(self):
'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 @@ def keep(item):
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 @@ def query(self):
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 @@ def query(self):
@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 @@ def GET_listing(self, where, vuser, sort, time, **env):
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 @@ def GET_about(self, vuser):
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
View
3  r2/r2/lib/pages/pages.py
@@ -1227,6 +1227,9 @@ def build_toolbars(self):
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")]

1 comment on commit 6ab11b3

@ichthyos

I think this commit may have caused issue 442. Could you take a look?

Please sign in to comment.
Something went wrong with that request. Please try again.