B
    `                 @   sn   d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	 eddZ
G dd	 d	ejZG d
d dejZdS )    )forms)gettext_lazy)pgettext_lazy)	get_model)URLDoesNotExistValidatorZ	flatpagesFlatPagec               @   s$   e Zd ZdZejdedddZdS )PageSearchFormz0
    Search form to filter pages by *title.
    Fz
Page titleZTitle)requiredlabelN)__name__
__module____qualname____doc__r   Z	CharFieldr   title r   r   O/home/dcms/DCMS/lib/python3.7/site-packages/oscar/apps/dashboard/pages/forms.pyr      s   r   c            	   @   sL   e Zd ZdZejeddddeddedid	Zd
d ZG dd dZ	dS )PageUpdateFormz
    Update form to create/update flatpages. It provides a *title*, *url*,
    and *content* field. The specified URL will be validated and check if
    the same URL already exists in the system.
    URLd   z^[-\w/\.~]+$FzExample: '/about/contact/'.invalidz\This value must contain only letters, numbers, dots, underscores, dashes, slashes or tildes.)r
   
max_lengthregexr	   	help_textZerror_messagesc             C   s4   | j d }d| jkr0|ds&|d7 }t | |S )z
        Validate the input for field *url* checking if the specified
        URL already exists. If it is an actual update and the URL has
        not been changed, validation will be skipped.

        Returns cleaned URL or raises an exception.
        url/)Zcleaned_dataZchanged_dataendswithr   )selfr   r   r   r   	clean_url'   s    



zPageUpdateForm.clean_urlc               @   s   e Zd ZeZdZdS )zPageUpdateForm.Meta)r   r   contentN)r   r   r   r   modelfieldsr   r   r   r   Meta6   s   r!   N)
r   r   r   r   r   Z
RegexField_r   r   r!   r   r   r   r   r      s   r   N)Zdjangor   Zdjango.utils.translationr   r"   r   Zoscar.core.loadingr   Zoscar.core.validatorsr   r   ZFormr   Z	ModelFormr   r   r   r   r   <module>   s   
