fix the bookmarklet to show you links from reddits you arent subscribed to

This commit is contained in:
spez
2009-02-03 15:50:37 -08:00
parent 70c7cc1652
commit 45043d5419
2 changed files with 16 additions and 12 deletions

View File

@@ -60,9 +60,7 @@ from r2.lib.promote import promote, unpromote, get_promoted
def link_listing_by_url(url, count = None):
"""
Generates a listing of links which share a common url, filtered by
the subreddit the current user is subscribed to (or the default
list of the user is not logged in.)
Generates a listing of links which share a common url
"""
try:
links = list(tup(Link._by_url(url, sr = c.site)))
@@ -72,10 +70,8 @@ def link_listing_by_url(url, count = None):
except NotFound:
links = ()
user = c.user if c.user_is_loggedin else None
names = [l._fullname for l in links
if l.sr_id in Subreddit.user_subreddits(user, limit = None)]
names = [l._fullname for l in links]
builder = IDBuilder(names, num = 25)
return LinkListing(builder).listing()

View File

@@ -477,12 +477,20 @@ class FrontController(RedditController):
redirect_link = listing.things[0]
# if there is more than one, check the users' subscriptions
else:
infotext = strings.multiple_submitted % \
listing.things[0].resubmit_link()
res = BoringPage(_("seen it"),
content = listing,
infotext = infotext).render()
return res
subscribed = [l for l in listing.things
if c.user_is_loggedin
and l.subreddit.is_subscriber_defaults(c.user)]
#if there is only 1 link to be displayed, just go there
if len(subscribed) == 1:
redirect_link = subscribed[0]
else:
infotext = strings.multiple_submitted % \
listing.things[0].resubmit_link()
res = BoringPage(_("seen it"),
content = listing,
infotext = infotext).render()
return res
# we've found a link already. Redirect to its permalink page
if redirect_link: