Skip to content

Commit

Permalink
Ignore mod bans when creating promoted links
Browse files Browse the repository at this point in the history
  • Loading branch information
kemitche authored and bsimpson63 committed Jan 25, 2012
1 parent e7b672d commit 05c9295
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
6 changes: 3 additions & 3 deletions r2/r2/controllers/promotecontroller.py
Expand Up @@ -244,7 +244,7 @@ def GET_roadblock(self):
reference_date = promote.promo_datetime_now,
business_days = False,
admin_override = True),
sr = VSubmitSR('sr'))
sr = VSubmitSR('sr', promotion=True))
def POST_add_roadblock(self, form, jquery, dates, sr):
if (form.has_errors('startdate', errors.BAD_DATE,
errors.BAD_FUTURE_DATE) or
Expand All @@ -267,7 +267,7 @@ def POST_add_roadblock(self, form, jquery, dates, sr):
reference_date = promote.promo_datetime_now,
business_days = False,
admin_override = True),
sr = VSubmitSR('sr'))
sr = VSubmitSR('sr', promotion=True))
def POST_rm_roadblock(self, form, jquery, dates, sr):
if dates and sr:
sd, ed = dates
Expand All @@ -283,7 +283,7 @@ def POST_rm_roadblock(self, form, jquery, dates, sr):
admin_override = True),
l = VLink('link_id'),
bid = VBid('bid', 'link_id', 'sr'),
sr = VSubmitSR('sr'),
sr = VSubmitSR('sr', promotion=True),
indx = VInt("indx"),
targeting = VLength("targeting", 10))
def POST_edit_campaign(self, form, jquery, l, indx,
Expand Down
5 changes: 3 additions & 2 deletions r2/r2/controllers/validator/validator.py
Expand Up @@ -789,8 +789,9 @@ def run(self, fullname, fullname2):
abort(403, "forbidden")

class VSubmitSR(Validator):
def __init__(self, srname_param, linktype_param = None):
def __init__(self, srname_param, linktype_param=None, promotion=False):
self.require_linktype = False
self.promotion = promotion

if linktype_param:
self.require_linktype = True
Expand All @@ -809,7 +810,7 @@ def run(self, sr_name, link_type = None):
self.set_error(errors.SUBREDDIT_NOEXIST)
return

if not c.user_is_loggedin or not sr.can_submit(c.user):
if not c.user_is_loggedin or not sr.can_submit(c.user, self.promotion):
self.set_error(errors.SUBREDDIT_NOTALLOWED)
return

Expand Down
4 changes: 2 additions & 2 deletions r2/r2/models/subreddit.py
Expand Up @@ -212,10 +212,10 @@ def can_comment(self, user):
else:
return False

def can_submit(self, user):
def can_submit(self, user, promotion=False):
if c.user_is_admin:
return True
elif self.is_banned(user):
elif self.is_banned(user) and not promotion:
return False
elif self.type == 'public':
return True
Expand Down

0 comments on commit 05c9295

Please sign in to comment.