Skip to content
Browse files

Future date limit on creating campaigns.

  • Loading branch information...
1 parent cac9702 commit b884ef23cc78892630f23fb98e4f05579b750ac6 @bsimpson63 bsimpson63 committed Sep 24, 2013
View
1 r2/example.ini
@@ -327,6 +327,7 @@ authorizenetkey =
min_promote_bid = 20
max_promote_bid = 9999
min_promote_future = 2
+max_promote_future = 93
# traffic log processing
TRAFFIC_ACCESS_KEY =
View
15 r2/r2/controllers/promotecontroller.py
@@ -509,10 +509,11 @@ def POST_rm_roadblock(self, form, jquery, dates, sr):
@validatedForm(VSponsor('link_id'),
VModhash(),
dates=VDateRange(['startdate', 'enddate'],
- earliest=promote.promo_datetime_now(offset=1),
- reference_date=promote.promo_datetime_now,
- business_days=True,
- sponsor_override=True),
+ earliest=promote.promo_datetime_now(offset=1),
+ latest=promote.promo_datetime_now(offset=g.max_promote_future),
+ reference_date=promote.promo_datetime_now,
+ business_days=True,
+ sponsor_override=True),
link=VLink('link_id'),
bid=VBid('bid', min=0, max=g.max_promote_bid,
coerce=False, error=errors.BAD_BID),
@@ -545,9 +546,9 @@ def POST_edit_campaign(self, form, jquery, link, campaign_id36,
field="startdate")
if (form.has_errors('startdate', errors.BAD_DATE,
- errors.DATE_TOO_EARLY) or
- form.has_errors('enddate', errors.BAD_DATE,
- errors.DATE_TOO_EARLY, errors.BAD_DATE_RANGE)):
+ errors.DATE_TOO_EARLY, errors.DATE_TOO_LATE) or
+ form.has_errors('enddate', errors.BAD_DATE, errors.DATE_TOO_EARLY,
+ errors.DATE_TOO_LATE, errors.BAD_DATE_RANGE)):
return
# Limit the number of PromoCampaigns a Link can have
View
1 r2/r2/lib/app_globals.py
@@ -128,6 +128,7 @@ class Globals(object):
'wiki_max_page_name_length',
'wiki_max_page_separators',
'min_promote_future',
+ 'max_promote_future',
],
ConfigValue.float: [
View
29 r2/r2/lib/pages/pages.py
@@ -3345,23 +3345,26 @@ def setup(self, link, listing):
)
self.bids.append(row)
- # reference "now" to what we use for promtions
+ # determine date range
now = promote.promo_datetime_now()
- # min date is the day before the first possible start date.
- self.promote_date_today = now
- mindate = make_offset_date(now, g.min_promote_future,
- business_days=True)
- mindate -= datetime.timedelta(1)
+ if c.user_is_sponsor:
+ mindate = now
+ elif promote.is_accepted(link):
+ mindate = make_offset_date(now, 1, business_days=True)
+ else:
+ mindate = make_offset_date(now, g.min_promote_future,
+ business_days=True)
- startdate = mindate + datetime.timedelta(1)
- enddate = startdate + datetime.timedelta(3)
+ maxstart = now + datetime.timedelta(days=g.max_promote_future-1)
+ self.maxstart = maxstart.strftime("%m/%d/%Y")
+ maxend = now + datetime.timedelta(days=g.max_promote_future)
+ self.maxend = maxend.strftime("%m/%d/%Y")
- self.startdate = startdate.strftime("%m/%d/%Y")
+ self.startdate = mindate.strftime("%m/%d/%Y")
+ enddate = mindate + datetime.timedelta(days=2)
self.enddate = enddate.strftime("%m/%d/%Y")
- self.mindate = mindate.strftime("%m/%d/%Y")
-
self.subreddit_selector = SubredditSelector()
self.link = promote.wrap_promoted(link)
@@ -3378,8 +3381,8 @@ def setup(self, link, listing):
srnames.update(names)
srs = Subreddit._by_name(srnames)
srs[''] = Frontpage
- inv_start = startdate
- inv_end = startdate + datetime.timedelta(days=14)
+ inv_start = mindate
+ inv_end = mindate + datetime.timedelta(days=14)
sr_inventory = inventory.get_available_pageviews(
srs.values(), inv_start, inv_end, datestr=True)
View
16 r2/r2/templates/promotelinkform.html
@@ -275,14 +275,12 @@
<tr>
<th>${_("start")}</th>
<td class="prefright">
- <%
- mindate = thing.startdate
- if c.user_is_sponsor:
- mindate = thing.promote_date_today.strftime('%m/%d/%Y')
- %>
- <input type="hidden" id="date-min" name="date-min" value="${mindate}" />
+ <input type="hidden" id="date-min" name="date-min" value="${thing.startdate}">
+ <input type="hidden" id="date-start-max" name="date-start-max" value="${thing.maxstart}">
+ <input type="hidden" id="date-end-max" name="date-end-max" value="${thing.maxend}">
<%self:datepicker name="startdate", value="${thing.startdate}"
- minDateSrc="date-min" initfuncname="init_startdate">
+ minDateSrc="date-min" maxDateSrc="date-start-max"
+ initfuncname="init_startdate">
function(elem) {
check_enddate(elem, $("#enddate"));
r.sponsored.on_date_change();
@@ -294,8 +292,8 @@
<th>${_("end")}</th>
<td class="prefright">
<%self:datepicker name="enddate", value="${thing.enddate}"
- minDateSrc="startdate" initfuncname="init_enddate"
- min_date_offset="86400000">
+ minDateSrc="startdate" maxDateSrc="date-end-max"
+ initfuncname="init_enddate" min_date_offset="86400000">
function(elem) { r.sponsored.on_date_change(); }
</%self:datepicker>
${error_field("BAD_DATE_RANGE", "enddate", "div")}

0 comments on commit b884ef2

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