本文整理汇总了Python中r2.lib.emailer.promo_bid函数的典型用法代码示例。如果您正苦于以下问题:Python promo_bid函数的具体用法?Python promo_bid怎么用?Python promo_bid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了promo_bid函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: auth_paid_promo
def auth_paid_promo(thing, user, pay_id, bid):
"""
promotes a promotion from 'unpaid' to 'unseen'.
In the case that bid already exists on the current promotion, the
previous transaction is voided and repalced with the new bid.
"""
if thing.promote_status == STATUS.finished:
return
elif (thing.promote_status > STATUS.unpaid and
thing.promote_trans_id):
# void the existing transaction
authorize.void_transaction(user, thing.promote_trans_id)
# create a new transaction and update the bid
trans_id = authorize.auth_transaction(bid, user, pay_id, thing)
thing.promote_bid = bid
if trans_id is not None:
# we won't reset to unseen if already approved and the payment went ok
promotion_log(thing, "updated payment and/or bid: SUCCESS")
if trans_id < 0:
promotion_log(thing, "FREEBIE")
thing.promote_status = max(thing.promote_status, STATUS.unseen)
thing.promote_trans_id = trans_id
else:
# something bad happend.
promotion_log(thing, "updated payment and/or bid: FAILED")
thing.promore_status = STATUS.unpaid
thing.promote_trans_id = 0
PromoteDates.update_bid(thing)
# commit last to guarantee consistency
thing._commit()
emailer.promo_bid(thing)
return bool(trans_id)
开发者ID:kevinrose,项目名称:diggit,代码行数:35,代码来源:promote.py
示例2: auth_campaign
def auth_campaign(link, index, user, pay_id):
"""
for setting up a campaign as a real bid with authorize.net
"""
with g.make_lock(campaign_lock(link)):
campaigns = getattr(link, "campaigns", {}).copy()
if index in campaigns:
# void any existing campaign
void_campaign(link, index, user)
sd, ed, bid, sr, trans_id = campaigns[index]
# create a new transaction and update the bid
test = 1 if g.debug else None
trans_id, reason = authorize.auth_transaction(bid, user,
pay_id, link,
index,
test = test)
if not reason and trans_id is not None and int(trans_id) != 0:
promotion_log(link, "updated payment and/or bid for campaign %s: "
"SUCCESS (trans_id: %d, amt: %0.2f)"
% (index, trans_id, bid))
if trans_id < 0:
promotion_log(link, "FREEBIE (campaign: %s)" % index)
set_status(link,
max(STATUS.unseen if trans_id else STATUS.unpaid,
link.promote_status))
# notify of campaign creation
# update the query queue
if user._id == link.author_id and trans_id > 0:
emailer.promo_bid(link, bid, sd)
else:
# something bad happend.
promotion_log(link, "updated payment and/or bid for campaign %s: FAILED ('%s')"
% (index, reason))
trans_id = 0
campaigns[index] = sd, ed, bid, sr, trans_id
link.campaigns = {}
link.campaigns = campaigns
link._commit()
# dual-write update to campaign Thing
campaign = PromoCampaign._byID(index)
if campaign:
if trans_id > 0:
campaign.mark_paid(trans_id)
elif trans_id < 0:
campaign.mark_freebie(trans_id)
else:
campaign.mark_payment_error(reason)
campaign._commit()
return bool(trans_id), reason
return False, ""
开发者ID:freekrai,项目名称:reddit,代码行数:56,代码来源:promote.py
示例3: auth_campaign
def auth_campaign(link, campaign, user, pay_id=None, freebie=False):
"""
Authorizes (but doesn't charge) a bid with authorize.net.
Args:
- link: promoted link
- campaign: campaign to be authorized
- user: Account obj of the user doing the auth (usually the currently
logged in user)
- pay_id: customer payment profile id to use for this transaction. (One
user can have more than one payment profile if, for instance, they have
more than one credit card on file.) Set pay_id to -1 for freebies.
Returns: (True, "") if successful or (False, error_msg) if not.
"""
void_campaign(link, campaign, reason='changed_payment')
if freebie:
trans_id, reason = authorize.auth_freebie_transaction(
campaign.bid, user, link, campaign._id)
else:
trans_id, reason = authorize.auth_transaction(
campaign.bid, user, pay_id, link, campaign._id)
if trans_id and not reason:
text = ('updated payment and/or bid for campaign %s: '
'SUCCESS (trans_id: %d, amt: %0.2f)' % (campaign._id, trans_id,
campaign.bid))
PromotionLog.add(link, text)
if trans_id < 0:
PromotionLog.add(link, 'FREEBIE (campaign: %s)' % campaign._id)
if trans_id:
if is_finished(link):
# When a finished promo gets a new paid campaign it doesn't
# need to go through approval again and is marked accepted
new_status = PROMOTE_STATUS.accepted
else:
new_status = max(PROMOTE_STATUS.unseen, link.promote_status)
else:
new_status = max(PROMOTE_STATUS.unpaid, link.promote_status)
update_promote_status(link, new_status)
if user and (user._id == link.author_id) and trans_id > 0:
emailer.promo_bid(link, campaign.bid, campaign.start_date)
else:
text = ("updated payment and/or bid for campaign %s: FAILED ('%s')"
% (campaign._id, reason))
PromotionLog.add(link, text)
trans_id = 0
campaign.trans_id = trans_id
campaign._commit()
return bool(trans_id), reason
开发者ID:pra85,项目名称:reddit,代码行数:55,代码来源:promote.py
示例4: auth_campaign
def auth_campaign(link, campaign_id, user, pay_id):
"""
Authorizes (but doesn't charge) a bid with authorize.net.
Args:
- link: promoted link
- campaign_id: long id of the campaign on link to be authorized
- user: Account obj of the user doing the auth (usually the currently
logged in user)
- pay_id: customer payment profile id to use for this transaction. (One
user can have more than one payment profile if, for instance, they have
more than one credit card on file.) Set pay_id to -1 for freebies.
Returns: (True, "") if successful or (False, error_msg) if not.
"""
try:
campaign = PromoCampaign._byID(campaign_id, data=True)
except NotFound:
g.log.error("Ignoring attempt to auth non-existent campaign: %d" %
campaign_id)
return False, "Campaign not found."
void_campaign(link, campaign_id)
test = 1 if g.debug else None
trans_id, reason = authorize.auth_transaction(campaign.bid, user, pay_id,
link, campaign_id, test=test)
if trans_id and not reason:
text = ('updated payment and/or bid for campaign %s: '
'SUCCESS (trans_id: %d, amt: %0.2f)' % (campaign_id, trans_id,
campaign.bid))
PromotionLog.add(link, text)
if trans_id < 0:
PromotionLog.add(link, 'FREEBIE (campaign: %s)' % campaign_id)
set_status(link,
max(STATUS.unseen if trans_id else STATUS.unpaid,
link.promote_status))
# notify of campaign creation
# update the query queue
if user and (user._id == link.author_id) and trans_id > 0:
emailer.promo_bid(link, campaign.bid, campaign.start_date)
else:
# something bad happend.
text = ("updated payment and/or bid for campaign %s: FAILED ('%s')"
% (campaign_id, reason))
PromotionLog.add(link, text)
trans_id = 0
campaign.trans_id = trans_id
campaign._commit()
return bool(trans_id), reason
开发者ID:topwinner,项目名称:reddit,代码行数:53,代码来源:promote.py
示例5: auth_campaign
def auth_campaign(link, campaign, user, pay_id):
"""
Authorizes (but doesn't charge) a bid with authorize.net.
Args:
- link: promoted link
- campaign: campaign to be authorized
- user: Account obj of the user doing the auth (usually the currently
logged in user)
- pay_id: customer payment profile id to use for this transaction. (One
user can have more than one payment profile if, for instance, they have
more than one credit card on file.) Set pay_id to -1 for freebies.
Returns: (True, "") if successful or (False, error_msg) if not.
"""
void_campaign(link, campaign)
test = 1 if g.debug else None
trans_id, reason = authorize.auth_transaction(campaign.bid, user, pay_id, link, campaign._id, test=test)
if trans_id and not reason:
text = "updated payment and/or bid for campaign %s: " "SUCCESS (trans_id: %d, amt: %0.2f)" % (
campaign._id,
trans_id,
campaign.bid,
)
PromotionLog.add(link, text)
if trans_id < 0:
PromotionLog.add(link, "FREEBIE (campaign: %s)" % campaign._id)
if trans_id:
new_status = max(PROMOTE_STATUS.unseen, link.promote_status)
else:
new_status = max(PROMOTE_STATUS.unpaid, link.promote_status)
set_promote_status(link, new_status)
# notify of campaign creation
# update the query queue
if user and (user._id == link.author_id) and trans_id > 0:
emailer.promo_bid(link, campaign.bid, campaign.start_date)
else:
# something bad happend.
text = "updated payment and/or bid for campaign %s: FAILED ('%s')" % (campaign._id, reason)
PromotionLog.add(link, text)
trans_id = 0
campaign.trans_id = trans_id
campaign._commit()
return bool(trans_id), reason
开发者ID:Kingofhearts102,项目名称:reddit,代码行数:48,代码来源:promote.py
示例6: auth_campaign
def auth_campaign(link, campaign_id, user, pay_id):
"""
Authorizes (but doesn't charge) a bid with authorize.net.
Args:
- link: promoted link
- campaign_id: long id of the campaign on link to be authorized
- user: Account obj of the user doing the auth (usually the currently
logged in user)
- pay_id: customer payment profile id to use for this transaction. (One
user can have more than one payment profile if, for instance, they have
more than one credit card on file.) Set pay_id to -1 for freebies.
Returns: (True, "") if successful or (False, error_msg) if not.
"""
try:
campaign = PromoCampaign._byID(campaign_id, data=True)
except NotFound:
g.log.error("Ignoring attempt to auth non-existent campaign: %d" % campaign_id)
return False, "Campaign not found."
void_campaign(link, campaign_id)
test = 1 if g.debug else None
trans_id, reason = authorize.auth_transaction(campaign.bid, user, pay_id, link, campaign_id, test=test)
if trans_id and not reason:
promotion_log(
link,
"updated payment and/or bid for campaign %s: "
"SUCCESS (trans_id: %d, amt: %0.2f)" % (campaign_id, trans_id, campaign.bid),
)
if trans_id < 0:
promotion_log(link, "FREEBIE (campaign: %s)" % campaign_id)
set_status(link, max(STATUS.unseen if trans_id else STATUS.unpaid, link.promote_status))
# notify of campaign creation
# update the query queue
if user and (user._id == link.author_id) and trans_id > 0:
emailer.promo_bid(link, campaign.bid, campaign.start_date)
else:
# something bad happend.
promotion_log(link, "updated payment and/or bid for campaign %s: FAILED ('%s')" % (campaign_id, reason))
trans_id = 0
campaign.trans_id = trans_id
campaign._commit()
# dual-write update to link attribute in case we need to roll back
with g.make_lock("promo_campaign", campaign_lock(link)):
campaigns = getattr(link, "campaigns", {}).copy()
if campaign_id in campaigns:
campaigns[campaign_id] = (
campaign.start_date,
campaign.end_date,
campaign.bid,
campaign.sr_name,
campaign.trans_id,
)
link.campaigns = {}
link.campaigns = campaigns
link._commit()
return bool(trans_id), reason
开发者ID:jianbin91,项目名称:reddit,代码行数:63,代码来源:promote.py
注:本文中的r2.lib.emailer.promo_bid函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论