3
W­E^£
  ã               @   s„   d dl mZ d dlmZ d dlmZ d dlmZmZm	Z	 d dl
mZ d dlmZ d dlmZ d dlmZ d	Zd
d„ Zedd„ ƒZdS )é    )Úsettings)ÚFlatPage)Úget_current_site)ÚHttp404ÚHttpResponseÚHttpResponsePermanentRedirect)Úget_object_or_404)Úloader)Ú	mark_safe)Úcsrf_protectzflatpages/default.htmlc             C   s†   |j dƒsd| }t| ƒj}ytt||d�}W nL tk
rz   |jdƒ rttjrt|d7 }tt||d�}t	d| j
 ƒS ‚ Y nX t| |ƒS )a3  
    Public interface to the flat page view.

    Models: `flatpages.flatpages`
    Templates: Uses the template defined by the ``template_name`` field,
        or :template:`flatpages/default.html` if template_name is not defined.
    Context:
        flatpage
            `flatpages.flatpages` object
    ú/)ÚurlÚsitesz%s/)Ú
startswithr   Úidr   r   r   Úendswithr   ZAPPEND_SLASHr   ÚpathÚrender_flatpage)Úrequestr   Zsite_idÚf© r   ú@/tmp/pip-build-78s3knkw/Django/django/contrib/flatpages/views.pyÚflatpage   s    

r   c             C   st   |j r&| jj r&ddlm} || jƒS |jr>tj|jt	fƒ}n
tj
t	ƒ}t|jƒ|_t|jƒ|_t|jd|i| ƒƒS )z3
    Internal interface to the flat page view.
    r   )Úredirect_to_loginr   )Zregistration_requiredÚuserÚis_authenticatedZdjango.contrib.auth.viewsr   r   Ztemplate_namer	   Zselect_templateÚDEFAULT_TEMPLATEZget_templater
   ÚtitleÚcontentr   Úrender)r   r   r   Útemplater   r   r   r   0   s    

r   N)Zdjango.confr   Zdjango.contrib.flatpages.modelsr   Zdjango.contrib.sites.shortcutsr   Zdjango.httpr   r   r   Zdjango.shortcutsr   Zdjango.templater	   Zdjango.utils.safestringr
   Zdjango.views.decorators.csrfr   r   r   r   r   r   r   r   Ú<module>   s   