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


Python MailSnake.listUnsubscribe方法代码示例

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


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

示例1: subscribe_update_cancel

# 需要导入模块: from mailsnake import MailSnake [as 别名]
# 或者: from mailsnake.MailSnake import listUnsubscribe [as 别名]
def subscribe_update_cancel(request):
    user = getUser(request)
    if request.POST:
        if "cancel_subscribe" in request.POST:
            user_profile = user.get_profile()

            # remove subscription
            stripe.api_key = settings.STRIPE_API_KEY
            cu = stripe.Customer.retrieve(user_profile.stripeprofile)
            cu.cancel_subscription()

            # remove from email list
            LIST_IDS = {"sflaunch_group": "eaa0a378ba"}
            l_id = LIST_IDS["sflaunch_group"]

            ms = MailSnake(settings.MAILCHIMP_API_KEY)
            success = ms.listUnsubscribe(id=l_id, email_address=user.email, send_notify=False)

            # email admin / email user
            subscription_cancel_email(user.email)

            # update userprofile
            sub = Subscription.objects.get(userprofile=user_profile)
            sub.subscription = False
            sub.subscription_type = "canceled"
            sub.save()
            messages.add_message(request, messages.SUCCESS, "Subscription canceled!")

            return redirect("/profile/manage")

        elif "update_stripe_cc" in request.POST:
            updateStripecc_Subscription(request)
            messages.add_message(request, messages.SUCCESS, "Credit card updated!")

    template = "profile/subscribe_update_cancel.html"

    init = {"country": "US"}
    payForm = PaymentForm(initial=init)

    customer = None
    if user:
        try:
            user_profile = user.get_profile()
            customer_id = user_profile.stripeprofile
            stripe.api_key = settings.STRIPE_API_KEY
            customer = stripe.Customer.retrieve(customer_id)
        except UserProfile.DoesNotExist:
            pass
        except stripe.InvalidRequestError:
            pass
        except AttributeError:
            pass

    change_card = False
    if "change_card" in request.GET:
        if request.GET.get("change_card") == "True":
            change_card = True

    data = {"customer": customer, "change_card": change_card, "payment": payForm, "user": user}

    return render_to_response(template, data, context_instance=RequestContext(request))
开发者ID:serkanh,项目名称:Yupeat,代码行数:63,代码来源:views.py


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