mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-04-27 03:00:12 -04:00
Disallow start date change if campaign has started
This commit is contained in:
@@ -1039,7 +1039,17 @@ class PromoteApiController(ApiController):
|
||||
|
||||
min_start, max_start, max_end = promote.get_date_limits(
|
||||
link, c.user_is_sponsor)
|
||||
if start.date() < min_start:
|
||||
|
||||
if campaign_id36:
|
||||
promo_campaign = PromoCampaign._byID36(campaign_id36)
|
||||
if (promote.is_promoted(link) and
|
||||
promo_campaign.start_date.date() <= min_start and
|
||||
start != promo_campaign.start_date and
|
||||
promo_campaign.is_paid):
|
||||
c.errors.add(errors.START_DATE_CANNOT_CHANGE, field='startdate')
|
||||
form.has_errors('startdate', errors.START_DATE_CANNOT_CHANGE)
|
||||
return
|
||||
elif start.date() < min_start:
|
||||
c.errors.add(errors.DATE_TOO_EARLY,
|
||||
msg_params={'day': min_start.strftime("%m/%d/%Y")},
|
||||
field='startdate')
|
||||
|
||||
@@ -100,6 +100,7 @@ error_list = dict((
|
||||
('BAD_DATE_RANGE', _('the dates need to be in order and not identical')),
|
||||
('DATE_TOO_LATE', _('please enter a date %(day)s or earlier')),
|
||||
('DATE_TOO_EARLY', _('please enter a date %(day)s or later')),
|
||||
('START_DATE_CANNOT_CHANGE', _('start date cannot be changed')),
|
||||
('BAD_ADDRESS', _('address problem: %(message)s')),
|
||||
('BAD_CARD', _('card problem: %(message)s')),
|
||||
('TOO_LONG', _("this is too long (max: %(max_length)s)")),
|
||||
|
||||
@@ -493,6 +493,10 @@ class PromoCampaign(Thing):
|
||||
else:
|
||||
return g.locations[self.location.country]['name']
|
||||
|
||||
@property
|
||||
def is_paid(self):
|
||||
return self.trans_id != 0 or self.priority == 'house'
|
||||
|
||||
def is_freebie(self):
|
||||
return self.trans_id < 0
|
||||
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
value="${value}" id="${name}" class="rounded styled-input" readonly="readonly" size="10" />
|
||||
<div id="datepicker-${name}" class="datepicker"></div>
|
||||
${error_field("BAD_DATE", name, "div")}
|
||||
${error_field("START_DATE_CANNOT_CHANGE", name, "div")}
|
||||
${error_field("DATE_TOO_EARLY", name, "div")}
|
||||
${error_field("DATE_TOO_LATE", name, "div")}
|
||||
<script type="text/javascript">
|
||||
|
||||
Reference in New Issue
Block a user