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:
shlurbee
2012-10-22 11:23:55 -07:00
parent 1da78397c3
commit aefb174c48
4 changed files with 24 additions and 6 deletions

View File

@@ -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()])

View File

@@ -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,

View File

@@ -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);
}
}
}
});

View File

@@ -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)"