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


Python Subscription.subscribe_for_the_first_time方法代码示例

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


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

示例1: subscriptions

# 需要导入模块: from subscription.models import Subscription [as 别名]
# 或者: from subscription.models.Subscription import subscribe_for_the_first_time [as 别名]
def subscriptions(request):
    group = get_last_used_group(request.user)

    context = base_context(request, group.id)

    try:
        subscription = Subscription.objects.get(user=request.user)
    except Subscription.DoesNotExist:
        Subscription.subscribe_for_the_first_time(request.user, request.user)

        subscription = Subscription.objects.get(user=request.user)

    waiting_payment_subscriptions = Payment.objects.filter(created_by=request.user, status=WAITING).order_by(
        "datetime_created"
    )

    subscriptions = Subscriptions.objects.filter(subscription=subscription).order_by("-datetime_created")

    my_payments = Payment.objects.filter(
        Q(status=PAID) | Q(status=NOT_ENOUGH_MONEY_ARRIVED) | Q(status=CANCELED), created_by=request.user
    ).order_by("-datetime_created")

    previous = None

    for wps in waiting_payment_subscriptions:
        wps.other_users_included_in_payment = wps.other_users_included_in_payment(request.user)
        wps.me_included = wps.me_included_in_payment(request.user)

        if wps.me_included:
            if not previous:
                wps.start_date = subscription.expiration_date
                wps.end_date = wps.start_date + datetime.timedelta(days=wps.subscription_duration * 31)
            else:
                wps.start_date = previous.end_date
                wps.end_date = wps.start_date + datetime.timedelta(days=wps.subscription_duration * 31)

            previous = wps

    context["sepa_address"] = settings.PAYMENT["sepa"]
    context["subscription"] = subscription
    context["waiting_payment_subscriptions"] = waiting_payment_subscriptions
    context["subscriptions"] = subscriptions
    context["my_payments"] = my_payments
    context["show_hide_canceled_button"] = False
    context["user"] = request.user
    context["subscription"] = Subscription.objects.get(user=request.user)
    # 'others_included': None,
    # 'past_subscriptions': past_subscriptions,
    context["title"] = _("My subscriptions")
    context["site_title"] = g.SITE_TITLE
    context["section"] = "settings"
    context["NOT_ENOUGH_MONEY_ARRIVED_STATUS"] = NOT_ENOUGH_MONEY_ARRIVED
    context["NO_MONEY_ARRIVED_STATUS"] = NO_MONEY_ARRIVED
    context["WAITING_STATUS"] = WAITING
    context["CANCELED_STATUS"] = CANCELED
    context["ALMOST_PAID_STATUS"] = ALMOST_PAID
    context["PAID_STATUS"] = PAID
    context["RUNNING_STATUS"] = RUNNING

    return render(request, "subscription/subscriptions.html", context)
开发者ID:rokj,项目名称:sellout,代码行数:62,代码来源:views.py

示例2: get_subscribed

# 需要导入模块: from subscription.models import Subscription [as 别名]
# 或者: from subscription.models.Subscription import subscribe_for_the_first_time [as 别名]
    def get_subscribed(self):
        from subscription.models import Subscription

        Subscription.subscribe_for_the_first_time(self, self)

        Subscription.move_from_email_to_user(self)

        try:
            subscription = Subscription.objects.get(user=self)
        except Subscription.DoesNotExist:
            return False

        if subscription.days_left > 0:
            return True

        return False
开发者ID:rokj,项目名称:sellout,代码行数:18,代码来源:models.py


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