3

\E                 @   sD   d dl mZ d dlmZ d dlmZ d dlmZ G dd deZdS )    )CheckoutSessionMixin)
exceptions)reverse)Subscriptionc               @   s   e Zd Zdd ZdS )r   c             C   s   d}d}xB|j jj D ]2}|jj }|jdkr2d}|jdkr|jjrd}qW |sTdS tjj	|j j
dj }|rtjtddd|o|stjtdd	ddS )
z
        Check whether there are starter kits in cart without -
        # A subscription , that is first for the given user
        :return:
        Fzstarter-kitsTz
coffee-bag)userzbasket:summaryzStarter kits can only be purchased with your first subscription. Please remove it from your basket to proceed with the checkout)urlmessagezStarter kits can only be purchased with a coffee bags subscription. Please add a coffee subscription or remove the starter kit to proceed with the checkout)basketlinesallproductget_product_classslugsubscriptionr   objectsfilterownerexistsr   FailedPreConditionr   )selfrequestZhas_starter_kitsZhas_subscription_productlineproduct_classZhas_subscription r   0/var/www/html/oscar2019/apps/checkout/session.py#check_sub_promo_without_sub_product	   s(    

z8CheckoutSessionMixin.check_sub_promo_without_sub_productN)__name__
__module____qualname__r   r   r   r   r   r      s   r   N)	Zoscar.apps.checkout.sessionr   Baseoscar.apps.checkoutr   django.shortcutsr   Zsubscription.modelsr   r   r   r   r   <module>   s   