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


Python Subscription.key方法代码示例

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


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

示例1: view_subscribe

# 需要导入模块: from models import Subscription [as 别名]
# 或者: from models.Subscription import key [as 别名]
def view_subscribe(request):

    # login is required here
    # if not ( request.user and request.user.is_authenticated() ):
    #    return HttpResponseRedirect()

    if request.user.subscription_set.count() >= Subscription._MAX_SUBSCRIPTIONS_PER_USER:
        Message(
            user=request.user,
            message=ugettext("You've reached maximum number of subscriptions. Delete some and try again."),
        ).put()
    elif request.method == "GET":
        search_form = AdvancedEventFilterForm(request.GET)

        if search_form.is_valid():

            country = Country.get_by_key_name(search_form.cleaned_data["country"])
            region = Region.get_by_key_name(search_form.cleaned_data["region"])
            free = search_form.cleaned_data["forfree"]

            if search_form.cleaned_data["forwho"] == "custom":
                event_types = 0
                for t in search_form.cleaned_data["typelist"]:
                    event_types += 1 << int(t)
            elif search_form.cleaned_data["forwho"] == "everyone":
                event_types = Event.OPEN_EVENTS_MASK
            else:
                # assert(search_form.cleaned_data['forwho'] == 'members')
                event_types = Event.MEMBERS_EVENTS_MASK

            s = Subscription(user=request.user, country=country, region=region, event_types=event_types, free=free)
            s.put()

            Message(user=request.user, message=ugettext("Subscription created")).put()

            return HttpResponseRedirect(
                reverse("events.views.view_event_list", kwargs={"subscription_id": s.key().id()})
            )

    return HttpResponseRedirect(reverse("events.views.view_event_list"))
开发者ID:fikander,项目名称:aolevents,代码行数:42,代码来源:views.py


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