3

\                 @   sb   d dl mZ d dlmZ d dlmZ G dd dejjZeG dd dej	Z
G dd	 d	e
Zd
S )    )models)Count)
deprecatedc               @   s   e Zd Zdd Zdd ZdS )ProductQuerySetc             C   s*   | j djdddddjtdtddS )zt
        Applies select_related and prefetch_related for commonly related
        models to save on queries
        product_classchildrenproduct_optionsZproduct_class__optionsstockrecordsimages)num_product_class_optionsnum_product_options)select_relatedprefetch_relatedannotater   )self r   8/var/www/html/oscar2019/oscar/apps/catalogue/managers.pybase_queryset	   s    
zProductQuerySet.base_querysetc             C   s   | j ddS )z2
        Excludes non-canonical products.
        N)parent)filter)r   r   r   r   	browsable   s    zProductQuerySet.browsableN)__name__
__module____qualname__r   r   r   r   r   r   r      s   
r   c               @   s(   e Zd ZdZdd Zdd Zdd ZdS )	ProductManagerz?
    Deprecated. Use ProductQuerySet.as_manager() instead.
    c             C   s   t | j| jdS )N)using)r   model_db)r   r   r   r   get_queryset    s    zProductManager.get_querysetc             C   s   | j  j S )N)r   r   )r   r   r   r   r   #   s    zProductManager.browsablec             C   s   | j  j S )N)r   r   )r   r   r   r   r   &   s    zProductManager.base_querysetN)r   r   r   __doc__r   r   r   r   r   r   r   r      s   r   c                   s$   e Zd ZdZe fddZ  ZS )BrowsableProductManagerz
    Deprecated. Use Product.objects.browsable() instead.

    The @deprecated decorator isn't applied to the class, because doing
    so would log warnings, and we still initialise this class
    in the Product.browsable for backward compatibility.
    c                s   t  j j S )N)superr   r   )r   )	__class__r   r   r   3   s    z$BrowsableProductManager.get_queryset)r   r   r   r   r   r   __classcell__r   r   )r"   r   r    *   s   r    N)	django.dbr   django.db.modelsr   Zoscar.core.decoratorsr   queryQuerySetr   Managerr   r    r   r   r   r   <module>   s   
