mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-04-27 03:00:12 -04:00
PromoteLinkForm: Display a summary of the promotion.
This commit is contained in:
@@ -3413,7 +3413,7 @@ class PromoteLinkForm(Templated):
|
||||
|
||||
self.link = link
|
||||
self.listing = listing
|
||||
campaigns = PromoCampaign._by_link(link._id)
|
||||
campaigns = list(PromoCampaign._by_link(link._id))
|
||||
self.campaigns = RenderableCampaign.from_campaigns(link, campaigns)
|
||||
self.promotion_log = PromotionLog.get(link)
|
||||
|
||||
@@ -3475,6 +3475,32 @@ class PromoteLinkForm(Templated):
|
||||
message %= {'link': 'http://www.slideshare.net/MikeCole1/brands-that-were-awesome-on-reddit-2013-30801823'}
|
||||
self.infobar = InfoBar(message=message)
|
||||
|
||||
if campaigns:
|
||||
subreddits = set()
|
||||
budget = 0.
|
||||
impressions = 0
|
||||
|
||||
for campaign in campaigns:
|
||||
subreddits.add(campaign.sr_name)
|
||||
budget += campaign.bid
|
||||
if hasattr(campaign, 'cpm') and campaign.priority.cpm:
|
||||
impressions += campaign.impressions
|
||||
|
||||
num_srs = len(subreddits)
|
||||
summary = ungettext("this promotion has a total budget of "
|
||||
"%(budget)s for %(impressions)s impressions in "
|
||||
"%(num)s subreddit",
|
||||
"this promotion has a total budget of "
|
||||
"%(budget)s for %(impressions)s impressions in "
|
||||
"%(num)s subreddits",
|
||||
num_srs)
|
||||
self.summary = summary % {
|
||||
'budget': format_currency(budget, 'USD', locale=c.locale),
|
||||
'impressions': format_number(impressions),
|
||||
'num': num_srs,
|
||||
}
|
||||
else:
|
||||
self.summary = None
|
||||
|
||||
class RenderableCampaign(Templated):
|
||||
def __init__(self, link, campaign, transaction, is_pending, is_live,
|
||||
|
||||
@@ -530,6 +530,17 @@ ${self.javascript_setup()}
|
||||
${_("You don't have any campaigns for this link yet. You should add one.")}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
%if thing.summary:
|
||||
<div class="help">
|
||||
<div class="infotext rounded">
|
||||
<p>
|
||||
${thing.summary}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
%endif
|
||||
|
||||
<span class="freebie error"></span>
|
||||
</%utils:line_field>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user