コード例 #1
0
ファイル: promote.py プロジェクト: Kingofhearts102/reddit
def accept_promotion(link):
    """
    Accepting is campaign agnostic.  Accepting the ad just means that
    it is allowed to run if payment has been processed.

    If a campagn is able to run, this also requeues it.
    """
    # update the query queue
    set_promote_status(link, PROMOTE_STATUS.accepted)

    # campaigns that should be live now must be updated
    now = promo_datetime_now(0)
    promotion_weights = PromotionWeights.get_campaigns(now)
    live_campaigns = {pw.promo_idx for pw in promotion_weights if pw.thing_name == link._fullname}
    if live_campaigns:
        campaigns = PromoCampaign._byID(live_campaigns, data=True, return_dict=False)
        PromotionLog.add(link, "has live campaigns, forcing live")
        charge_pending(0)  # campaign must be charged before it will go live
        for campaign in campaigns:
            hooks.get_hook("campaign.edit").call(link=link, campaign=campaign)
        queue_changed_promo(link, "accepted")

    # campaigns that were charged and will go live in the future must be updated
    future_campaigns = [camp for camp in PromoCampaign._by_link(link._id) if camp.start_date > now]
    transactions = get_transactions(link, future_campaigns)
    charged_campaigns = [
        camp for camp in future_campaigns if (transactions.get(camp._id) and transactions.get(camp._id).is_charged())
    ]
    for campaign in charged_campaigns:
        hooks.get_hook("campaign.edit").call(link=link, campaign=campaign)

    if link._spam:
        link._spam = False
        link._commit()
    emailer.accept_promo(link)
コード例 #2
0
ファイル: promote.py プロジェクト: AHAMED750/reddit
def accept_promotion(link):
    was_edited_live = is_edited_live(link)
    update_promote_status(link, PROMOTE_STATUS.accepted)

    if link._spam:
        link._spam = False
        link._commit()

    if not was_edited_live:
        emailer.accept_promo(link)

    # if the link has campaigns running now charge them and promote the link
    now = promo_datetime_now()
    campaigns = list(PromoCampaign._by_link(link._id))
    is_live = False
    for camp in campaigns:
        if is_accepted_promo(now, link, camp):
            # if link was edited live, do not check against Authorize.net
            if not was_edited_live:
                charge_campaign(link, camp)
            if charged_or_not_needed(camp):
                promote_link(link, camp)
                is_live = True

    if is_live:
        all_live_promo_srnames(_update=True)
コード例 #3
0
def accept_promotion(link):
    was_edited_live = is_edited_live(link)
    update_promote_status(link, PROMOTE_STATUS.accepted)

    if link._spam:
        link._spam = False
        link._commit()

    if not was_edited_live:
        emailer.accept_promo(link)

    # if the link has campaigns running now charge them and promote the link
    now = promo_datetime_now()
    campaigns = list(PromoCampaign._by_link(link._id))
    is_live = False
    for camp in campaigns:
        if is_accepted_promo(now, link, camp):
            # if link was edited live, do not check against Authorize.net
            if not was_edited_live:
                charge_campaign(link, camp)
            if charged_or_not_needed(camp):
                promote_link(link, camp)
                is_live = True

    if is_live:
        all_live_promo_srnames(_update=True)
コード例 #4
0
ファイル: promote.py プロジェクト: Hmaal/reddit
def accept_promotion(link):
    """
    Accepting is campaign agnostic.  Accepting the ad just means that
    it is allowed to run if payment has been processed.

    If a campagn is able to run, this also requeues it.
    """
    PromotionLog.add(link, 'status update: accepted')
    # update the query queue

    set_promote_status(link, PROMOTE_STATUS.accepted)

    # campaigns that should be live now must be updated
    now = promo_datetime_now(0)
    if link._fullname in set(l.thing_name for l in
                             PromotionWeights.get_campaigns(now)):
        PromotionLog.add(link, 'Marked promotion for acceptance')
        charge_pending(0) # campaign must be charged before it will go live
        queue_changed_promo(link, "accepted")

    # campaigns that were charged and will go live in the future must be updated
    future_campaigns = [camp for camp in PromoCampaign._by_link(link._id)
                        if camp.start_date > now]
    transactions = get_transactions(link, future_campaigns)
    charged_campaigns = [camp for camp in future_campaigns
                         if (transactions.get(camp._id) and
                             transactions.get(camp._id).is_charged())]
    for campaign in charged_campaigns:
        hooks.get_hook('campaign.edit').call(link=link, campaign=campaign)

    if link._spam:
        link._spam = False
        link._commit()
    emailer.accept_promo(link)
コード例 #5
0
def accept_promotion(link):
    """
    Accepting is campaign agnostic.  Accepting the ad just means that
    it is allowed to run if payment has been processed.

    If a campagn is able to run, this also requeues it.
    """
    # update the query queue
    set_promote_status(link, PROMOTE_STATUS.accepted)

    # campaigns that should be live now must be updated
    now = promo_datetime_now(0)
    promotion_weights = PromotionWeights.get_campaigns(now)
    live_campaigns = {
        pw.promo_idx
        for pw in promotion_weights if pw.thing_name == link._fullname
    }
    if live_campaigns:
        campaigns = PromoCampaign._byID(live_campaigns,
                                        data=True,
                                        return_dict=False)
        PromotionLog.add(link, 'has live campaigns, forcing live')
        charge_pending(0)  # campaign must be charged before it will go live
        for campaign in campaigns:
            hooks.get_hook('campaign.edit').call(link=link, campaign=campaign)
        queue_changed_promo(link, "accepted")

    # campaigns that were charged and will go live in the future must be updated
    future_campaigns = [
        camp for camp in PromoCampaign._by_link(link._id)
        if camp.start_date > now
    ]
    transactions = get_transactions(link, future_campaigns)
    charged_campaigns = [
        camp for camp in future_campaigns
        if (transactions.get(camp._id)
            and transactions.get(camp._id).is_charged())
    ]
    for campaign in charged_campaigns:
        hooks.get_hook('campaign.edit').call(link=link, campaign=campaign)

    if link._spam:
        link._spam = False
        link._commit()
    emailer.accept_promo(link)
コード例 #6
0
ファイル: promote.py プロジェクト: JediWatchman/reddit
def accept_promotion(link):
    """
    Accepting is campaign agnostic.  Accepting the ad just means that
    it is allowed to run if payment has been processed.

    If a campagn is able to run, this also requeues it.
    """
    promotion_log(link, "status update: accepted")
    # update the query queue

    set_status(link, STATUS.accepted)
    now = promo_datetime_now(0)
    if link._fullname in set(l.thing_name for l in
                             PromotionWeights.get_campaigns(now)):
        promotion_log(link, "requeued")
        #TODO: smarter would be nice, but this will have to do for now
        make_daily_promotions()
    emailer.accept_promo(link)
コード例 #7
0
ファイル: promote.py プロジェクト: saferadar/coderaid-reddit
def accept_promotion(link):
    """
    Accepting is campaign agnostic.  Accepting the ad just means that
    it is allowed to run if payment has been processed.

    If a campagn is able to run, this also requeues it.
    """
    promotion_log(link, "status update: accepted")
    # update the query queue

    set_status(link, STATUS.accepted)
    now = promo_datetime_now(0)
    if link._fullname in set(l.thing_name
                             for l in PromotionWeights.get_campaigns(now)):
        promotion_log(link, "requeued")
        #TODO: smarter would be nice, but this will have to do for now
        make_daily_promotions()
    emailer.accept_promo(link)
コード例 #8
0
ファイル: promote.py プロジェクト: kevinrose/diggit
def accept_promo(thing):
    """
    Accept promotion and set its status as accepted if not already
    charged, else pending.
    """
    if thing.promote_status < STATUS.pending:
        bid = Bid.one(thing.promote_trans_id)
        if bid.status == Bid.STATUS.CHARGE:
            thing.promote_status = STATUS.pending
            # repromote if already promoted before
            if hasattr(thing, "promoted_on"):
                promote(thing)
            else:
                emailer.queue_promo(thing)
        else:
            thing.promote_status = STATUS.accepted
            promotion_log(thing, "status update: accepted")    
            emailer.accept_promo(thing)
        thing._commit()
コード例 #9
0
ファイル: promote.py プロジェクト: jianbin91/reddit
def accept_promotion(link):
    """
    Accepting is campaign agnostic.  Accepting the ad just means that
    it is allowed to run if payment has been processed.

    If a campagn is able to run, this also requeues it.
    """
    promotion_log(link, "status update: accepted")
    # update the query queue

    set_status(link, STATUS.accepted)
    now = promo_datetime_now(0)
    if link._fullname in set(l.thing_name for l in PromotionWeights.get_campaigns(now)):
        promotion_log(link, "requeued")
        charge_pending(0)  # campaign must be charged before it will go live
        make_daily_promotions()
    if link._spam:
        link._spam = False
        link._commit()
    emailer.accept_promo(link)
コード例 #10
0
def accept_promotion(link):
    """
    Accepting is campaign agnostic.  Accepting the ad just means that
    it is allowed to run if payment has been processed.

    If a campagn is able to run, this also requeues it.
    """
    PromotionLog.add(link, 'status update: accepted')
    # update the query queue

    set_promote_status(link, PROMOTE_STATUS.accepted)
    now = promo_datetime_now(0)
    if link._fullname in set(l.thing_name
                             for l in PromotionWeights.get_campaigns(now)):
        PromotionLog.add(link, 'Marked promotion for acceptance')
        charge_pending(0)  # campaign must be charged before it will go live
        queue_changed_promo(link, "accepted")
    if link._spam:
        link._spam = False
        link._commit()
    emailer.accept_promo(link)
コード例 #11
0
ファイル: promote.py プロジェクト: vinnydiehl/reddit
def accept_promotion(link):
    """
    Accepting is campaign agnostic.  Accepting the ad just means that
    it is allowed to run if payment has been processed.

    If a campagn is able to run, this also requeues it.
    """
    PromotionLog.add(link, 'status update: accepted')
    # update the query queue

    set_promote_status(link, PROMOTE_STATUS.accepted)
    now = promo_datetime_now(0)
    if link._fullname in set(l.thing_name for l in
                             PromotionWeights.get_campaigns(now)):
        PromotionLog.add(link, 'Marked promotion for acceptance')
        charge_pending(0) # campaign must be charged before it will go live
        queue_changed_promo(link, "accepted")
    if link._spam:
        link._spam = False
        link._commit()
    emailer.accept_promo(link)
コード例 #12
0
ファイル: promote.py プロジェクト: DanHoerst/reddit
def accept_promotion(link):
    """
    Accepting is campaign agnostic.  Accepting the ad just means that
    it is allowed to run if payment has been processed.

    If a campagn is able to run, this also requeues it.
    """
    promotion_log(link, "status update: accepted")
    # update the query queue

    set_status(link, STATUS.accepted)
    now = promo_datetime_now(0)
    if link._fullname in set(l.thing_name
                             for l in PromotionWeights.get_campaigns(now)):
        promotion_log(link, "requeued")
        charge_pending(0)  # campaign must be charged before it will go live
        make_daily_promotions()
    if link._spam:
        link._spam = False
        link._commit()
    emailer.accept_promo(link)