3

‘ã\Þ  ã               @   s<   d dl mZ d dlZd dlmZ dd„ Zdd„ Zdd	„ ZdS )
é    )ÚsettingsN)ÚValidationErrorc              C   sJ   g } | j dƒ ttdƒ}x,tj|ƒD ]}|jƒ r$| j |j|jfƒ q$W | S )zâ
    Gets all the sub dirs of the directory templates > catalogue > custom
    All custom templates need to have a list and detail template
    These are used to display different designs for different product categories.
    NÚDefaultÚCUSTOM_CATALOGUE_TEMPLATES_DIR)Nr   )ÚappendÚgetattrr   ÚosÚscandirÚis_dirÚname)ÚretÚtemplates_dirÚitem© r   ú1/var/www/html/oscar2019/apps/catalogue/helpers.pyÚget_category_templates   s    

r   c             C   s@   t tdƒ}tjjt tdƒdƒ}tjj|| |d ƒ}tjj||ƒS )zd
    Returns the template path
    :param template_name:
    :param template_type:
    :return:
    r   ÚBASE_DIRÚ	templatesz.html)r   r   r   ÚpathÚjoinÚrelpath)Útemplate_nameZtemplate_typer   Ztemplates_base_dirZtemplate_filer   r   r   Úget_template   s    
r   c             C   s   | j jdƒstdƒ‚d S )Nz.jpgzOnly JPG files are allowed)r   Úendswithr   )Úvaluer   r   r   Úvalidate_file_extension$   s    r   )Údjango.confr   r   Údjango.core.exceptionsr   r   r   r   r   r   r   r   Ú<module>   s
   