3

\-                 @   s   d dl mZ d dlmZ d dlmZ d dlmZ eddZeddZ	G dd dej
Z
G d	d
 d
ejZG dd dejZG dd dejZG dd dejZG dd dejZdS )    )forms)get_category_templates)	get_model	catalogueOptionProductClassc               @   s    e Zd ZG dd dejjZdS )ProductClassFormc               @   s   e Zd ZeZdddddgZdS )zProductClassForm.Metanamerequires_shippingtrack_stockfront_end_viewoptionsN)__name__
__module____qualname__r   modelfields r   r   9/var/www/html/oscar2019/apps/dashboard/catalogue/forms.pyMeta   s   r   N)r   r   r   
base_formsr   r   r   r   r   r   r   
   s   r   c               @   s2   e Zd ZejeejddZG dd dej	j
Z
dS )CategoryFormF)choiceswidgetrequiredc               @   s   e Zd ZddddgZdS )zCategoryForm.Metar	   descriptionimagetemplateN)r   r   r   r   r   r   r   r   r      s   r   N)r   r   r   r   ChoiceFieldr   Selectr   r   r   r   r   r   r   r   r      s   
r   c               @   s   e Zd ZG dd dZdS )
OptionFormc               @   s   e Zd ZdddgZeZdS )zOptionForm.Metar	   typedisplay_typeN)r   r   r   r   r   r   r   r   r   r   r      s   
r   N)r   r   r   r   r   r   r   r   r       s   r    c               @   s    e Zd ZG dd dejjZdS )ProductAttributesFormc               @   s    e Zd ZddddddddgZd	S )
zProductAttributesForm.Metar	   coder!   option_groupr   use_for_variationsdisplayuse_for_filterN)r   r   r   r   r   r   r   r   r      s   r   N)r   r   r   r   r#   r   r   r   r   r   r#      s   r#   c               @   s0   e Zd ZejdejdZG dd dejj	Z	dS )ProductCategoryFormF)r   r   c               @   s   e Zd ZddgZdS )zProductCategoryForm.MetacategoryprimaryN)r   r   r   r   r   r   r   r   r   &   s   r   N)
r   r   r   r   BooleanFieldCheckboxInputr+   r   r)   r   r   r   r   r   r)   #   s   r)   c               @   s.   e Zd ZdZG dd dejjZdddZdS )	ProductFormzn
    Replacing the product form from oscar to display only the variable attributes for the child products
    c               @   s*   e Zd Zddddddddd	d
dddgZdS )zProductForm.Metatitleupcr   is_discountable	structuresubscriptionfeaturedshipping_weightstrike_priceliveloyalty_pointslabel
label_dripN)r   r   r   r   r   r   r   r   r   /   s   r   Fc             C   s   | j jr|jjddj }n
|jj }x||D ]t}| j|}|r,|| jd|j < |jdkrt	j
ddid| jd|j  _dg| jd|j  _|r,d| jd|j  _q,W d	S )
z
        For each attribute specified by the product class, this method
        dynamically adds form fields to the product form.
        T)r&   zattr_%sdatezdata-oscarWidget)attrsz%y-%m-%dFN)instanceparent
attributesfilterallget_attribute_fieldr   r$   r!   r   	DateInputr   input_formatsr   )selfproduct_class	is_parentr?   	attributefieldr   r   r   add_attribute_fields4   s    



z ProductForm.add_attribute_fieldsN)F)r   r   r   __doc__r   r.   r   rJ   r   r   r   r   r.   *   s   r.   N)oscar.apps.dashboard.cataloguer   r   djangoZapps.catalogue.helpersr   oscar.core.loadingr   r   r   r   r   	ModelFormr    r#   r)   r.   r   r   r   r   <module>   s   

