ó
J~Pc           @   sÄ   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	 m
 Z
 m Z d  d l m Z d  d l m Z m Z d  d l m Z d  d	 l m Z d
 Z d   Z e d    Z d S(   i˙˙˙˙(   t   settings(   t   FlatPage(   t   get_current_site(   t   populate_xheaders(   t   Http404t   HttpResponset   HttpResponsePermanentRedirect(   t   get_object_or_404(   t   loadert   RequestContext(   t	   mark_safe(   t   csrf_protects   flatpages/default.htmlc         C   sˇ   | j  d  s d | } n  t |   j } y t t d | d | } Wn` t k
 rŠ | j d  rŁ t j rŁ | d 7} t t d | d | } t	 d |  j
  S  n Xt |  |  S(   s3  
    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
    t   /t
   url__exactt   sites__id__exacts   %s/(   t
   startswithR   t   idR   R   R   t   endswithR    t   APPEND_SLASHR   t   patht   render_flatpage(   t   requestt   urlt   site_idt   f(    (    s7   ../Django//lib/python/django/contrib/flatpages/views.pyt   flatpage   s    	
	c         C   sŇ   | j  r6 |  j j   r6 d d l m } | |  j  S| j rZ t j | j t	 f  } n t j
 t	  } t | j  | _ t | j  | _ t |  i | d 6 } t | j |   } t |  | t | j  | S(   s3   
    Internal interface to the flat page view.
    i˙˙˙˙(   t   redirect_to_loginR   (   t   registration_requiredt   usert   is_authenticatedt   django.contrib.auth.viewsR   R   t   template_nameR   t   select_templatet   DEFAULT_TEMPLATEt   get_templateR
   t   titlet   contentR	   R   t   renderR   R   R   (   R   R   R   t   tt   ct   response(    (    s7   ../Django//lib/python/django/contrib/flatpages/views.pyR   0   s    		N(   t   django.confR    t   django.contrib.flatpages.modelsR   t   django.contrib.sites.modelsR   t   django.core.xheadersR   t   django.httpR   R   R   t   django.shortcutsR   t   django.templateR   R	   t   django.utils.safestringR
   t   django.views.decorators.csrfR   R!   R   R   (    (    (    s7   ../Django//lib/python/django/contrib/flatpages/views.pyt   <module>   s   
	