Add AllMinusBox sidebox.

This commit is contained in:
bsimpson63
2012-11-19 11:26:03 -05:00
parent 9d2a1af184
commit 6b3ee4bb70
3 changed files with 57 additions and 1 deletions

View File

@@ -22,7 +22,7 @@
from r2.lib.wrapped import Wrapped, Templated, CachedTemplate
from r2.models import Account, FakeAccount, DefaultSR, make_feedurl
from r2.models import FakeSubreddit, Subreddit, Ad, AdSR, SubSR
from r2.models import FakeSubreddit, Subreddit, Ad, AdSR, SubSR, AllMinus, AllSR
from r2.models import Friends, All, Sub, NotFound, DomainSR, Random, Mod, RandomNSFW, MultiReddit, ModSR, Frontpage
from r2.models import Link, Printable, Trophy, bidding, PromoCampaign, PromotionWeights, Comment
from r2.models import Flair, FlairTemplate, FlairTemplateBySubredditIndex
@@ -319,6 +319,10 @@ class Reddit(Templated):
box = SubscriptionBox(srs)
ps.append(SideContentBox(_('these subreddits'), [box]))
if (isinstance(c.site, AllMinus) or
isinstance(c.site, AllSR) and c.user.gold):
ps.append(AllMinusBox(c.user))
# don't show the subreddit info bar on cnames unless the option is set
if not isinstance(c.site, FakeSubreddit) and (not c.cname or c.site.show_cname_sidebar):
ps.append(SubredditInfoBar())
@@ -1694,6 +1698,22 @@ class SubscriptionBox(Templated):
def reddits(self):
return wrap_links(self.srs)
class AllMinusBox(Templated):
def __init__(self, user):
if user.gold:
sr_ids = Subreddit.user_subreddits(user)
srs = Subreddit._byID(sr_ids, data=True, return_dict=False)
path = '/r/all'
if srs:
path += '-' + '-'.join([sr.name for sr in srs])
text = _('See /r/all minus your subscribed subreddits')
else:
path = '/gold'
text = _('/r/all filtering is a gold only feature')
Templated.__init__(self, text=text, path=path)
class CreateSubreddit(Templated):
"""reddit creation form."""
def __init__(self, site = None, name = ''):

View File

@@ -5045,6 +5045,15 @@ tr.gold-accent + tr > td {
padding-top: 10px;
}
.allminus-box {
padding: 5px;
margin: 0;
}
.allminus-box a {
font-size: small;
}
#per-sr-karma {
width: 300px;
margin: .6em auto 0 auto;

View File

@@ -0,0 +1,27 @@
## The contents of this file are subject to the Common Public Attribution
## License Version 1.0. (the "License"); you may not use this file except in
## compliance with the License. You may obtain a copy of the License at
## http://code.reddit.com/LICENSE. The License is based on the Mozilla Public
## License Version 1.1, but Sections 14 and 15 have been added to cover use of
## software over a computer network and provide for limited attribution for the
## Original Developer. In addition, Exhibit A has been modified to be
## consistent with Exhibit B.
##
## Software distributed under the License is distributed on an "AS IS" basis,
## WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
## the specific language governing rights and limitations under the License.
##
## The Original Code is reddit.
##
## The Original Developer is the Initial Developer. The Initial Developer of
## the Original Code is reddit Inc.
##
## All portions of the code written by reddit are Copyright (c) 2006-2012
## reddit Inc. All Rights Reserved.
###############################################################################
<div class="allminus-box gold-accent rounded">
<span class="giftgold">
<a href="${thing.path}">${thing.text}</a>
</span>
</div>