当前位置: 首页>>代码示例>>Python>>正文


Python RNewUserQueue.user_position方法代码示例

本文整理汇总了Python中apps.profile.models.RNewUserQueue.user_position方法的典型用法代码示例。如果您正苦于以下问题:Python RNewUserQueue.user_position方法的具体用法?Python RNewUserQueue.user_position怎么用?Python RNewUserQueue.user_position使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在apps.profile.models.RNewUserQueue的用法示例。


在下文中一共展示了RNewUserQueue.user_position方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: stripe_form

# 需要导入模块: from apps.profile.models import RNewUserQueue [as 别名]
# 或者: from apps.profile.models.RNewUserQueue import user_position [as 别名]
def stripe_form(request):
    user = request.user
    success_updating = False
    stripe.api_key = settings.STRIPE_SECRET
    plan = int(request.GET.get('plan', 2))
    plan = PLANS[plan-1][0]
    error = None
    
    if request.method == 'POST':
        zebra_form = StripePlusPaymentForm(request.POST, email=user.email)
        if zebra_form.is_valid():
            user.email = zebra_form.cleaned_data['email']
            user.save()
            
            try:
                customer = stripe.Customer.create(**{
                    'card': zebra_form.cleaned_data['stripe_token'],
                    'plan': zebra_form.cleaned_data['plan'],
                    'email': user.email,
                    'description': user.username,
                })
            except stripe.CardError:
                error = "This card was declined."
            else:
                user.profile.strip_4_digits = zebra_form.cleaned_data['last_4_digits']
                user.profile.stripe_id = customer.id
                user.profile.save()
                user.profile.activate_premium() # TODO: Remove, because webhooks are slow

                success_updating = True

    else:
        zebra_form = StripePlusPaymentForm(email=user.email, plan=plan)
    
    if success_updating:
        return render_to_response('reader/paypal_return.xhtml', 
                                  {}, context_instance=RequestContext(request))
    
    new_user_queue_count = RNewUserQueue.user_count()
    new_user_queue_position = RNewUserQueue.user_position(request.user.pk)
    new_user_queue_behind = 0
    if new_user_queue_position >= 0:
        new_user_queue_behind = new_user_queue_count - new_user_queue_position 
        new_user_queue_position -= 1
    
    logging.user(request, "~BM~FBLoading Stripe form")

    return render_to_response('profile/stripe_form.xhtml',
        {
          'zebra_form': zebra_form,
          'publishable': settings.STRIPE_PUBLISHABLE,
          'success_updating': success_updating,
          'new_user_queue_count': new_user_queue_count - 1,
          'new_user_queue_position': new_user_queue_position,
          'new_user_queue_behind': new_user_queue_behind,
          'error': error,
        },
        context_instance=RequestContext(request)
    )
开发者ID:Daniel-Hug,项目名称:NewsBlur,代码行数:61,代码来源:views.py

示例2: stripe_form

# 需要导入模块: from apps.profile.models import RNewUserQueue [as 别名]
# 或者: from apps.profile.models.RNewUserQueue import user_position [as 别名]
def stripe_form(request):
    user = request.user
    success_updating = False
    stripe.api_key = settings.STRIPE_SECRET
    plan = int(request.GET.get("plan", 2))
    plan = PLANS[plan - 1][0]

    if request.method == "POST":
        zebra_form = StripePlusPaymentForm(request.POST, email=user.email)
        if zebra_form.is_valid():
            user.email = zebra_form.cleaned_data["email"]
            user.save()

            customer = stripe.Customer.create(
                **{
                    "card": zebra_form.cleaned_data["stripe_token"],
                    "plan": zebra_form.cleaned_data["plan"],
                    "email": user.email,
                    "description": user.username,
                }
            )

            user.profile.strip_4_digits = zebra_form.cleaned_data["last_4_digits"]
            user.profile.stripe_id = customer.id
            user.profile.save()
            user.profile.activate_premium()  # TODO: Remove, because webhooks are slow

            success_updating = True

    else:
        zebra_form = StripePlusPaymentForm(email=user.email, plan=plan)

    if success_updating:
        return render_to_response("reader/paypal_return.xhtml", {}, context_instance=RequestContext(request))

    new_user_queue_count = RNewUserQueue.user_count()
    new_user_queue_position = RNewUserQueue.user_position(request.user.pk)
    new_user_queue_behind = 0
    if new_user_queue_position >= 0:
        new_user_queue_behind = new_user_queue_count - new_user_queue_position
        new_user_queue_position -= 1

    logging.user(request, "~BM~FBLoading Stripe form")

    return render_to_response(
        "profile/stripe_form.xhtml",
        {
            "zebra_form": zebra_form,
            "publishable": settings.STRIPE_PUBLISHABLE,
            "success_updating": success_updating,
            "new_user_queue_count": new_user_queue_count - 1,
            "new_user_queue_position": new_user_queue_position,
            "new_user_queue_behind": new_user_queue_behind,
        },
        context_instance=RequestContext(request),
    )
开发者ID:bayunox,项目名称:NewsBlur,代码行数:58,代码来源:views.py

示例3: stripe_form

# 需要导入模块: from apps.profile.models import RNewUserQueue [as 别名]
# 或者: from apps.profile.models.RNewUserQueue import user_position [as 别名]
def stripe_form(request):
    user = request.user
    success_updating = False
    stripe.api_key = settings.STRIPE_SECRET
    plan = int(request.GET.get("plan", 2))
    plan = PLANS[plan - 1][0]
    error = None

    if request.method == "POST":
        zebra_form = StripePlusPaymentForm(request.POST, email=user.email)
        if zebra_form.is_valid():
            user.email = zebra_form.cleaned_data["email"]
            user.save()

            current_premium = (
                user.profile.is_premium
                and user.profile.premium_expire
                and user.profile.premium_expire > datetime.datetime.now()
            )
            # Are they changing their existing card?
            if user.profile.stripe_id and current_premium:
                customer = stripe.Customer.retrieve(user.profile.stripe_id)
                try:
                    card = customer.cards.create(card=zebra_form.cleaned_data["stripe_token"])
                except stripe.CardError:
                    error = "This card was declined."
                else:
                    customer.default_card = card.id
                    customer.save()
                    success_updating = True
            else:
                try:
                    customer = stripe.Customer.create(
                        **{
                            "card": zebra_form.cleaned_data["stripe_token"],
                            "plan": zebra_form.cleaned_data["plan"],
                            "email": user.email,
                            "description": user.username,
                        }
                    )
                except stripe.CardError:
                    error = "This card was declined."
                else:
                    user.profile.strip_4_digits = zebra_form.cleaned_data["last_4_digits"]
                    user.profile.stripe_id = customer.id
                    user.profile.save()
                    user.profile.activate_premium()  # TODO: Remove, because webhooks are slow
                    success_updating = True

    else:
        zebra_form = StripePlusPaymentForm(email=user.email, plan=plan)

    if success_updating:
        return render_to_response("reader/paypal_return.xhtml", {}, context_instance=RequestContext(request))

    new_user_queue_count = RNewUserQueue.user_count()
    new_user_queue_position = RNewUserQueue.user_position(request.user.pk)
    new_user_queue_behind = 0
    if new_user_queue_position >= 0:
        new_user_queue_behind = new_user_queue_count - new_user_queue_position
        new_user_queue_position -= 1

    logging.user(request, "~BM~FBLoading Stripe form")

    return render_to_response(
        "profile/stripe_form.xhtml",
        {
            "zebra_form": zebra_form,
            "publishable": settings.STRIPE_PUBLISHABLE,
            "success_updating": success_updating,
            "new_user_queue_count": new_user_queue_count - 1,
            "new_user_queue_position": new_user_queue_position,
            "new_user_queue_behind": new_user_queue_behind,
            "error": error,
        },
        context_instance=RequestContext(request),
    )
开发者ID:jmorahan,项目名称:NewsBlur,代码行数:79,代码来源:views.py

示例4: stripe_form

# 需要导入模块: from apps.profile.models import RNewUserQueue [as 别名]
# 或者: from apps.profile.models.RNewUserQueue import user_position [as 别名]
def stripe_form(request):
    user = request.user
    success_updating = False
    stripe.api_key = settings.STRIPE_SECRET
    plan = int(request.GET.get('plan', 2))
    plan = PLANS[plan-1][0]
    renew = is_true(request.GET.get('renew', False))
    error = None
    
    if request.method == 'POST':
        zebra_form = StripePlusPaymentForm(request.POST, email=user.email)
        if zebra_form.is_valid():
            user.email = zebra_form.cleaned_data['email']
            user.save()
            
            grace_period = datetime.datetime.now() - datetime.timedelta(days=30)
            current_premium = (user.profile.is_premium and 
                               user.profile.premium_expire and
                               user.profile.premium_expire > grace_period)
            # Are they changing their existing card?
            if user.profile.stripe_id and current_premium:
                customer = stripe.Customer.retrieve(user.profile.stripe_id)
                try:
                    card = customer.cards.create(card=zebra_form.cleaned_data['stripe_token'])
                except stripe.CardError:
                    error = "This card was declined."
                else:
                    customer.default_card = card.id
                    customer.save()
                    success_updating = True
            else:
                try:
                    customer = stripe.Customer.create(**{
                        'card': zebra_form.cleaned_data['stripe_token'],
                        'plan': zebra_form.cleaned_data['plan'],
                        'email': user.email,
                        'description': user.username,
                    })
                except stripe.CardError:
                    error = "This card was declined."
                else:
                    user.profile.strip_4_digits = zebra_form.cleaned_data['last_4_digits']
                    user.profile.stripe_id = customer.id
                    user.profile.save()
                    user.profile.activate_premium() # TODO: Remove, because webhooks are slow
                    success_updating = True

    else:
        zebra_form = StripePlusPaymentForm(email=user.email, plan=plan)
    
    if success_updating:
        return render_to_response('reader/paypal_return.xhtml', 
                                  {}, context_instance=RequestContext(request))
    
    new_user_queue_count = RNewUserQueue.user_count()
    new_user_queue_position = RNewUserQueue.user_position(request.user.pk)
    new_user_queue_behind = 0
    if new_user_queue_position >= 0:
        new_user_queue_behind = new_user_queue_count - new_user_queue_position 
        new_user_queue_position -= 1
    
    immediate_charge = True
    if user.profile.premium_expire and user.profile.premium_expire > datetime.datetime.now():
        immediate_charge = False
    
    logging.user(request, "~BM~FBLoading Stripe form")

    return render_to_response('profile/stripe_form.xhtml',
        {
          'zebra_form': zebra_form,
          'publishable': settings.STRIPE_PUBLISHABLE,
          'success_updating': success_updating,
          'new_user_queue_count': new_user_queue_count - 1,
          'new_user_queue_position': new_user_queue_position,
          'new_user_queue_behind': new_user_queue_behind,
          'renew': renew,
          'immediate_charge': immediate_charge,
          'error': error,
        },
        context_instance=RequestContext(request)
    )
开发者ID:MilenkoM,项目名称:NewsBlur,代码行数:83,代码来源:views.py


注:本文中的apps.profile.models.RNewUserQueue.user_position方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。