Skip to content

Commit

Permalink
Make sr discovery links respect gold user preferences
Browse files Browse the repository at this point in the history
Subreddit discovery links are basically sponsored links, so they shouldn't
appear if gold users have sponsored links turned off
  • Loading branch information
shlurbee authored and kemitche committed Jul 26, 2012
1 parent a2f7a90 commit 5d67249
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions r2/r2/controllers/listingcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,26 +256,24 @@ def spotlight(self):
and (not c.user_is_loggedin
or (c.user_is_loggedin and c.user.pref_organic))):

# Spotlight shows rising links. If available, mix in subreddit
# discovery links as well. (These don't count towards ad bids)
spotlight_links = organic.organic_links(c.user)
if hasattr(g, 'sr_discovery_links'):
spotlight_links.extend(g.sr_discovery_links)
random.shuffle(spotlight_links)
spotlight_keep_fn = lambda l: promote.is_promo(l) or organic.keep_fresh_links(l)
num_links = len(spotlight_links)
else:
spotlight_keep_fn = organic.keep_fresh_links
num_links = organic.organic_length


pos = organic_pos()

if not spotlight_links:
pos = 0
elif pos != 0:
pos = pos % len(spotlight_links)
spotlight_keep_fn = organic.keep_fresh_links
num_links = organic.organic_length

# If prefs allow it, mix in promoted links and sr discovery content
if c.user.pref_show_sponsors or not c.user.gold:
if hasattr(g, 'sr_discovery_links'):
spotlight_links.extend(g.sr_discovery_links)
random.shuffle(spotlight_links)
spotlight_keep_fn = lambda l: promote.is_promo(l) or organic.keep_fresh_links(l)
num_links = len(spotlight_links)
spotlight_links, pos = promote.insert_promoted(spotlight_links, pos)

# Need to do this again, because if there was a duplicate removed,
Expand Down

0 comments on commit 5d67249

Please sign in to comment.