From 15d60fb82d2611e036d685120ca9f228f892c043 Mon Sep 17 00:00:00 2001 From: shlurbee Date: Thu, 16 Aug 2012 17:20:52 -0700 Subject: [PATCH] Fixes bugs in promotion code: Updates an occurrence of "index" that should have been changed to campaign._id during the campaign thing reads change. This fixes two bugs: (1) Campaigns were being incorrectly marked with "update failed" when edited by an admin or sponsor even though the update was successful. (2) Campaigns were not being automatically marked as freebies when edited by an admin or sponsor. (These have to be set as freebies in self-serve because they are billed separately.) This change also checks for an empty user string so the update function can be run in paster shell. --- r2/r2/lib/promote.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/r2/r2/lib/promote.py b/r2/r2/lib/promote.py index 7397e2491..f0c404d13 100644 --- a/r2/r2/lib/promote.py +++ b/r2/r2/lib/promote.py @@ -461,7 +461,7 @@ def edit_campaign(link, campaign_id, dates, bid, sr): # make it a freebie, if applicable author = Account._byID(link.author_id, True) if getattr(author, "complimentary_promos", False): - free_campaign(link, index, c.user) + free_campaign(link, campaign._id, c.user) except Exception, e: # record error and rethrow g.log.error("Failed to update PromoCampaign %s on link %d. Error was: %r" % @@ -544,7 +544,7 @@ def auth_campaign(link, campaign_id, user, pay_id): link.promote_status)) # notify of campaign creation # update the query queue - if user._id == link.author_id and trans_id > 0: + if user and (user._id == link.author_id) and trans_id > 0: emailer.promo_bid(link, campaign.bid, campaign.start_date) else: