mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-04-05 03:00:15 -04:00
Allow sponsors/admins to edit live campaign
Allows admins/sponsors to edit some campaign fields even after the ad has gone live. Target can be changed at any time. Bid can only be changed for freebies.
This commit is contained in:
@@ -111,6 +111,7 @@ error_list = dict((
|
||||
('TOO_MANY_DEVELOPERS', _('too many developers')),
|
||||
('BAD_HASH', _("i don't believe you.")),
|
||||
('ALREADY_MODERATOR', _('that user is already a moderator')),
|
||||
('BID_LIVE', _('you cannot edit the bid of a live ad'))
|
||||
))
|
||||
errors = Storage([(e, e) for e in error_list.keys()])
|
||||
|
||||
|
||||
@@ -338,6 +338,18 @@ class PromoteController(ListingController):
|
||||
else:
|
||||
min_daily_bid = g.min_promote_bid
|
||||
|
||||
# you cannot edit the bid of a live ad unless it's a freebie
|
||||
try:
|
||||
campaign = PromoCampaign._byID(indx)
|
||||
if (bid != campaign.bid and
|
||||
campaign.start_date < datetime.now(g.tz)
|
||||
and not campaign.is_freebie()):
|
||||
c.errors.add(errors.BID_LIVE, field='bid')
|
||||
form.has_errors('bid', errors.BID_LIVE)
|
||||
return
|
||||
except NotFound:
|
||||
pass
|
||||
|
||||
if bid is None or bid / duration < min_daily_bid:
|
||||
c.errors.add(errors.BAD_BID, field = 'bid',
|
||||
msg_params = {'min': min_daily_bid,
|
||||
|
||||
@@ -113,13 +113,11 @@ function get_flag_class(flags) {
|
||||
if(flags.complete) {
|
||||
css_class += " complete";
|
||||
}
|
||||
else {
|
||||
if(flags.sponsor) {
|
||||
css_class += " sponsor";
|
||||
}
|
||||
if(flags.paid) {
|
||||
else if (flags.paid) {
|
||||
css_class += " paid";
|
||||
}
|
||||
}
|
||||
if (flags.sponsor) {
|
||||
css_class += " sponsor";
|
||||
}
|
||||
return css_class
|
||||
}
|
||||
@@ -220,6 +218,12 @@ $.set_up_campaigns = function() {
|
||||
else {
|
||||
$(td).append("<span class='info'>complete/live</span>");
|
||||
$(bid_td).addClass("paid")
|
||||
/* sponsors can always edit */
|
||||
if (tr.hasClass("sponsor")) {
|
||||
var e = $(edit).addClass("edit fancybutton")
|
||||
.click(function() { edit_campaign(tr); });
|
||||
$(td).append(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -136,6 +136,7 @@ ${unsafe(js.use('sponsored'))}
|
||||
<th>total bid</th>
|
||||
<td class="prefright">
|
||||
${error_field("BAD_BID", "bid", "div")}
|
||||
${error_field("BID_LIVE", "bid", "div")}
|
||||
$<input id="bid" name="bid" size="7" type="text" class="rounded styled-input"
|
||||
style="width:auto"
|
||||
onchange="update_bid(this)"
|
||||
|
||||
Reference in New Issue
Block a user