validators.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:planet-b-saleor 作者: planet-b 项目源码 文件源码
def validate_shipping_address(view):
    """Decorate a view making it require a valid shipping address.

    Expects to be decorated with `@validate_cart`.

    If either the shipping address or customer email is empty redirects to the
    shipping address step.
    """
    @wraps(view)
    def func(request, checkout):
        if checkout.email is None or checkout.shipping_address is None:
            return redirect('checkout:shipping-address')
        try:
            checkout.shipping_address.full_clean()
        except ValidationError:
            return redirect('checkout:shipping-address')
        return view(request, checkout)
    return func
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号