mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-28 08:17:58 -05:00
Per user CPM overrides.
This commit is contained in:
@@ -89,6 +89,7 @@ from r2.lib.validator import (
|
||||
VUrl,
|
||||
)
|
||||
from r2.models import (
|
||||
Account,
|
||||
calc_impressions,
|
||||
Frontpage,
|
||||
Link,
|
||||
@@ -532,7 +533,9 @@ class PromoteController(ListingController):
|
||||
return
|
||||
|
||||
start, end = dates or (None, None)
|
||||
cpm = g.cpm_selfserve.pennies
|
||||
|
||||
author = Account._byID(link.author_id, data=True)
|
||||
cpm = author.cpm_selfserve_pennies
|
||||
|
||||
if (start and end and not promote.is_accepted(link) and
|
||||
not c.user_is_sponsor):
|
||||
|
||||
@@ -3318,8 +3318,9 @@ class PromoteLinkForm(Templated):
|
||||
|
||||
def setup(self, link, listing):
|
||||
self.bids = []
|
||||
self.author = Account._byID(link.author_id, data=True)
|
||||
|
||||
if c.user_is_sponsor:
|
||||
self.author = Account._byID(link.author_id, data=True)
|
||||
try:
|
||||
bids = bidding.Bid.lookup(thing_id=link._id)
|
||||
except NotFound:
|
||||
|
||||
@@ -644,6 +644,12 @@ class Account(Thing):
|
||||
self.name in g.sponsors or
|
||||
self.name in g.employees))
|
||||
|
||||
@property
|
||||
def cpm_selfserve_pennies(self):
|
||||
return getattr(self, 'cpm_selfserve_pennies_override',
|
||||
g.cpm_selfserve.pennies)
|
||||
|
||||
|
||||
class FakeAccount(Account):
|
||||
_nodb = True
|
||||
pref_no_profanity = True
|
||||
|
||||
@@ -309,7 +309,7 @@ ${self.javascript_setup()}
|
||||
<tr>
|
||||
<th>${_("price")}</th>
|
||||
<td class="prefright">
|
||||
<input id="cpm" name="cpm" value="${g.cpm_selfserve.pennies}" type="hidden">
|
||||
<input id="cpm" name="cpm" value="${thing.author.cpm_selfserve_pennies}" type="hidden">
|
||||
<span class="price-info"></span>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -326,7 +326,7 @@ ${self.javascript_setup()}
|
||||
onkeyup="r.sponsored.on_bid_change()"
|
||||
value="${format_decimal(5 * thing.min_bid, format='.00', locale=c.locale)}"
|
||||
data-min_bid="${thing.min_bid}"
|
||||
data-base_cpm="${g.cpm_selfserve.pennies}"/>
|
||||
data-base_cpm="${thing.author.cpm_selfserve_pennies}"/>
|
||||
<div class="minimum-spend">
|
||||
${_('%(minimum)s minimum') % dict(minimum=format_currency(thing.min_bid, 'USD', locale=c.locale))}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user