mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-27 15:58:06 -05:00
Fix another corner case in promote.accept_promotion.
Campaign that has been charged but won't go live until the future must be updated. Also added a comment for the other corner case.
This commit is contained in:
@@ -498,12 +498,25 @@ def accept_promotion(link):
|
||||
# update the query queue
|
||||
|
||||
set_promote_status(link, PROMOTE_STATUS.accepted)
|
||||
|
||||
# campaigns that should be live now must be updated
|
||||
now = promo_datetime_now(0)
|
||||
if link._fullname in set(l.thing_name for l in
|
||||
PromotionWeights.get_campaigns(now)):
|
||||
PromotionLog.add(link, 'Marked promotion for acceptance')
|
||||
charge_pending(0) # campaign must be charged before it will go live
|
||||
queue_changed_promo(link, "accepted")
|
||||
|
||||
# campaigns that were charged and will go live in the future must be updated
|
||||
future_campaigns = [camp for camp in PromoCampaign._by_link(link._id)
|
||||
if camp.start_date > now]
|
||||
transactions = get_transactions(link, future_campaigns)
|
||||
charged_campaigns = [camp for camp in future_campaigns
|
||||
if (transactions.get(camp._id) and
|
||||
transactions.get(camp._id).is_charged())]
|
||||
for campaign in charged_campaigns:
|
||||
hooks.get_hook('campaign.edit').call(link=link, campaign=campaign)
|
||||
|
||||
if link._spam:
|
||||
link._spam = False
|
||||
link._commit()
|
||||
|
||||
Reference in New Issue
Block a user