本文整理汇总了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"))