def send_mail(request): key = None try: key = request.POST.get("key", None) if key is None: raise Http404 subscription = Subscription.get(key) if subscription is None: raise Http404 # quick fix for running tasks if subscription.email == "": subscription.activated_mail = False subscription.put() return HttpResponse("Skipping early.") context = subscription.get_message_context() if context is None: return HttpResponse("Nothing to do.") subscription.check_beacon_status(datetime.datetime.now()) subject = "Seriesly.com - %d new episodes" % len(context["items"]) body = render_to_string("subscription_mail.txt", RequestContext(request, context)) except Exception, e: logging.error(e) return HttpResponse("Done (with errors): %s" % key)
def post_to_callback(request): key = None webhook = None try: key = request.POST.get("key", None) if key is None: raise Http404 subscription = Subscription.get(key) if subscription is None: raise Http404 subscription.check_beacon_status(datetime.datetime.now()) context = subscription.get_message_context() if context is None: return HttpResponse("Nothing to do.") body = render_to_string("subscription_webhook.xml", RequestContext(request, context)) webhook = subscription.webhook try: subscription.post_to_callback(body) except Exception, e: subscription.webhook = None logging.warn("Webhook failed (%s): %s" % (key, e)) subscription.put()
def set_next_airtime(request): key = None key = request.POST.get("key", None) if key is None: raise Http404 subscription = Subscription.get(key) subscription.next_airtime = datetime.date(2010, 1, 1) subscription.put() return HttpResponse("Done: %s" % key)
def set_next_airtime(request): key = None key = request.POST.get("key", None) if key is None: raise Http404 subscription = Subscription.get(key) subscription.next_airtime = datetime.date(2010,1,1) subscription.put() return HttpResponse("Done: %s" % key)
def send_confirm_mail(request): key = None try: key = request.POST.get("key", None) if key is None: raise Http404 subscription = Subscription.get(key) if subscription is None: raise Http404 except Exception, e: logging.error(e) return HttpResponse("Done (with errors): %s" % key)
def send_xmpp(request): key = None try: key = request.POST.get("key", None) if key is None: raise Http404 subscription = Subscription.get(key) if subscription is None: raise Http404 subscription.check_beacon_status(datetime.datetime.now()) context = subscription.get_message_context() if context is None: return HttpResponse("Nothing to do.") body = render_to_string("subscription_xmpp.txt", RequestContext(request, context)) except Exception, e: logging.error(e) return HttpResponse("Done (with errors): %s" % key)