示例#1
0
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)
示例#2
0
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()
示例#3
0
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)
示例#4
0
文件: views.py 项目: AnaCm/seriesly
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)
示例#5
0
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)
示例#6
0
文件: views.py 项目: AnaCm/seriesly
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)
示例#7
0
文件: views.py 项目: AnaCm/seriesly
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)
示例#8
0
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)
示例#9
0
文件: views.py 项目: AnaCm/seriesly
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()
示例#10
0
文件: views.py 项目: AnaCm/seriesly
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)