From ac6657832aebad6065261b3ed74e83be8134f095 Mon Sep 17 00:00:00 2001 From: Brian Simpson Date: Mon, 19 Aug 2013 13:07:36 -0700 Subject: [PATCH] finalize_completed_campaigns: be careful with cpm attribute. --- r2/r2/lib/promote.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/r2/r2/lib/promote.py b/r2/r2/lib/promote.py index 46e028d58..ce778f95e 100644 --- a/r2/r2/lib/promote.py +++ b/r2/r2/lib/promote.py @@ -780,8 +780,12 @@ def finalize_completed_campaigns(daysago=1): billable_amount = get_billable_amount(camp, billable_impressions) if billable_amount >= camp.bid: - text = ('%s completed with $%s billable (%s impressions @ $%s).' - % (camp, billable_amount, billable_impressions, camp.cpm)) + if hasattr(camp, 'cpm'): + text = '%s completed with $%s billable (%s impressions @ $%s).' + text %= (camp, billable_amount, billable_impressions, camp.cpm) + else: + text = '%s completed with $%s billable (pre-CPM).' + text %= (camp, billable_amount) PromotionLog.add(link, text) refund_amount = 0. else: