本文整理汇总了Python中subscription.models.Subscription.all方法的典型用法代码示例。如果您正苦于以下问题:Python Subscription.all方法的具体用法?Python Subscription.all怎么用?Python Subscription.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类subscription.models.Subscription
的用法示例。
在下文中一共展示了Subscription.all方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: show
# 需要导入模块: from subscription.models import Subscription [as 别名]
# 或者: from subscription.models.Subscription import all [as 别名]
def show(request, subkey, extra_context=None):
subscription = Subscription.all().filter("subkey =", subkey).get()
if subscription is None:
raise Http404
if extra_context is None:
extra_context = {}
if "mail_form" in extra_context:
subscription.mail_form = extra_context["mail_form"]
else:
subscription.mail_form = MailSubscriptionForm({"email": subscription.email, "subkey": subkey})
if "xmpp_form" in extra_context:
subscription.xmpp_form = extra_context["xmpp_form"]
else:
subscription.xmpp_form = XMPPSubscriptionForm({"xmpp": subscription.xmpp, "subkey": subkey})
if "webhook_form" in extra_context:
subscription.webhook_form = extra_context["webhook_form"]
else:
subscription.webhook_form = WebHookSubscriptionForm({"webhook": subscription.webhook, "subkey": subkey})
if "public_id_form" in extra_context:
subscription.public_id_form = extra_context["public_id_form"]
else:
subscription.public_id_form = SubscriptionKeyForm({"subkey": subkey})
subscription.sub_settings = subscription.get_settings()
response = render_to_response("subscription.html", RequestContext(request,
{"shows": subscription.get_shows(), "subscription":subscription}))
response.set_cookie("subkey", subkey, max_age=31536000)
return response
示例2: clean_subkey
# 需要导入模块: from subscription.models import Subscription [as 别名]
# 或者: from subscription.models.Subscription import all [as 别名]
def clean_subkey(self):
subkey = self.cleaned_data["subkey"]
sub = Subscription.all().filter("subkey =", subkey).get()
if sub is None:
raise forms.ValidationError("You don't have a valid Seriesly Subscription Key")
self._subscription = sub
return subkey
示例3: webhook_task
# 需要导入模块: from subscription.models import Subscription [as 别名]
# 或者: from subscription.models.Subscription import all [as 别名]
def webhook_task(request):
"""BadFilterError: invalid filter: Only one property per query may have inequality filters (<=, >=, <, >).."""
subscriptions = Subscription.all().filter("webhook !=", None)
counter = 0
for obj in subscriptions:
Subscription.add_webhook_task(obj.key())
counter += 1
return HttpResponse("Done: added %d" % counter)
示例4: json_public
# 需要导入模块: from subscription.models import Subscription [as 别名]
# 或者: from subscription.models.Subscription import all [as 别名]
def json_public(request, public_id):
subscription = Subscription.all().filter("public_id =", public_id).get()
if subscription is None:
raise Http404
response = _guide(request, subscription, template="widget.json",
public=True, extra_context=get_extra_json_context(request))
response["Content-Type"] = 'application/json'
return response
示例5: clean
# 需要导入模块: from subscription.models import Subscription [as 别名]
# 或者: from subscription.models.Subscription import all [as 别名]
def clean(self):
cleaned_data = self.cleaned_data
if cleaned_data["xmpp"] != "":
sub = Subscription.all().filter("xmpp =", cleaned_data["xmpp"]).filter("subkey !=", self._subscription.subkey).get()
if sub is not None:
self._errors["xmpp"] = forms.util.ErrorList(["This XMPP address already belongs to a subscription."])
del cleaned_data["xmpp"]
return cleaned_data
示例6: xmpp_task
# 需要导入模块: from subscription.models import Subscription [as 别名]
# 或者: from subscription.models.Subscription import all [as 别名]
def xmpp_task(request):
subscription_keys = Subscription.all(keys_only=True).filter("activated_xmpp =", True)
# .filter("next_airtime <", datetime.datetime.now().date())
counter = 0
for key in subscription_keys:
Subscription.add_xmpp_task(key)
counter += 1
return HttpResponse("Done: added %d" % counter)
示例7: subscriptions
# 需要导入模块: from subscription.models import Subscription [as 别名]
# 或者: from subscription.models.Subscription import all [as 别名]
def subscriptions(request):
now = datetime.datetime.now()
threshold = now - datetime.timedelta(days=30*3)
subcount = 0
for subscription in Subscription.all():
if subscription.last_visited is not None and subscription.last_visited > threshold:
subcount += 1
return HttpResponse("Done: \n%d" % subcount)
示例8: feed
# 需要导入模块: from subscription.models import Subscription [as 别名]
# 或者: from subscription.models.Subscription import all [as 别名]
def feed(request, subkey, template):
subscription = Subscription.all().filter("subkey =", subkey).get()
if subscription is None:
raise Http404
body = _feed(request, subscription, template)
mimetype = "application/atom+xml"
if "rss" in template:
mimetype = "application/rss+xml"
return HttpResponse(body, mimetype=mimetype)
示例9: email_task
# 需要导入模块: from subscription.models import Subscription [as 别名]
# 或者: from subscription.models.Subscription import all [as 别名]
def email_task(request):
filter_date = datetime.datetime.now().date() + datetime.timedelta(days=1)
subscription_keys = Subscription.all(keys_only=True).filter("activated_mail =", True)\
.filter("next_airtime <=", filter_date)
counter = 0
for key in subscription_keys:
Subscription.add_email_task(key)
counter += 1
return HttpResponse("Done: added %d" % counter)
示例10: confirm_mail
# 需要导入模块: from subscription.models import Subscription [as 别名]
# 或者: from subscription.models.Subscription import all [as 别名]
def confirm_mail(request, subkey, confirmkey):
subscription = Subscription.all().filter("subkey =", subkey).get()
if subscription is None:
raise Http404
if subscription.check_confirmation_key(confirmkey):
if subscription.activated_mail == False and subscription.email != "":
subscription.activated_mail = True
subscription.put()
return HttpResponseRedirect(subscription.get_absolute_url() + "#email")
else:
raise Http404
示例11: edit
# 需要导入模块: from subscription.models import Subscription [as 别名]
# 或者: from subscription.models.Subscription import all [as 别名]
def edit(request, subkey):
subscription = Subscription.all().filter("subkey =", subkey).get()
if subscription is None:
raise Http404
if request.method == "GET":
sub_settings = subscription.get_settings()
sub_dict = {"email": subscription.email,
"shows": map(lambda x: x.idnr, subscription.get_shows()),
"subkey": subkey}
form = SubscriptionForm(sub_dict)
return index(request, form=form, extra_context={"subscription": subscription})
return HttpResponseRedirect(subscription.get_absolute_url())
示例12: show_public
# 需要导入模块: from subscription.models import Subscription [as 别名]
# 或者: from subscription.models.Subscription import all [as 别名]
def show_public(request, public_id):
subscription = Subscription.all().filter("public_id =", public_id).get()
if subscription is None:
raise Http404
response = render_to_response("subscription_public.html",
RequestContext(
request,
{
"shows": subscription.get_shows(),
"subscription": subscription
}
))
return response
示例13: feed_atom_public
# 需要导入模块: from subscription.models import Subscription [as 别名]
# 或者: from subscription.models.Subscription import all [as 别名]
def feed_atom_public(request, public_id, template="atom_public.xml"):
subscription = Subscription.all().filter("public_id =", public_id).get()
if subscription is None:
raise Http404
now = datetime.datetime.now()
if subscription.needs_update(subscription.feed_public_stamp, now):
subscription.check_beacon_status(now)
# don't specify encoding for unicode strings!
subscription.feed_public_cache = db.Text(_feed(request, subscription, template, public=True))
subscription.feed_public_stamp = now
try:
subscription.put() # this put is not highly relevant
except Exception, e:
logging.warning(e)
示例14: feed_rss_public
# 需要导入模块: from subscription.models import Subscription [as 别名]
# 或者: from subscription.models.Subscription import all [as 别名]
def feed_rss_public(request, public_id, template="rss_public.xml"):
subscription = Subscription.all().filter("public_id =", public_id).get()
if subscription is None:
raise Http404
return HttpResponse(_feed(request, subscription, template, public=True), mimetype="application/rss+xml")
示例15: add_next_airtime_task
# 需要导入模块: from subscription.models import Subscription [as 别名]
# 或者: from subscription.models.Subscription import all [as 别名]
def add_next_airtime_task(request):
for key in Subscription.all(keys_only=True).filter("activated_mail =", True):
t = taskqueue.Task(url="/subscription/next-airtime/", params={"key": str(key)})
t.add(queue_name="webhook-queue")
return HttpResponse("Done: ")