File: //usr/lib/python3/dist-packages/django/contrib/flatpages/__pycache__/views.cpython-310.pyc
o
�a�
� @ s� d dl mZ d dlmZ d dlmZ d dlmZmZm Z d dl
mZ d dlm
Z
d dlmZ d dlmZ d Zd
d� Zedd
� �ZdS )� )�settings)�FlatPage)�get_current_site)�Http404�HttpResponse�HttpResponsePermanentRedirect)�get_object_or_404)�loader)� mark_safe)�csrf_protectzflatpages/default.htmlc C s� |� d�s d| }t| �j}z tt||d�}W n$ ty; |�d�s:tjr:|d7 }tt||d�}t d| j
� Y S � w 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 �APPEND_SLASHr �path�render_flatpage)�requestr
�site_id�f� r �@/usr/lib/python3/dist-packages/django/contrib/flatpages/views.py�flatpage s
�
r c C sr |j r| jjsddlm} || j�S |jrt�|jt f�}nt�
t �}t|j�|_t|j
�|_
t|�d|i| ��S )z3
Internal interface to the flat page view.
r )�redirect_to_loginr )�registration_required�user�is_authenticated�django.contrib.auth.viewsr r �
template_namer �select_template�DEFAULT_TEMPLATE�get_templater
�title�contentr �render)r r r �templater r r r 0 s
r N)�django.confr �django.contrib.flatpages.modelsr �django.contrib.sites.shortcutsr �django.httpr r r �django.shortcutsr �django.templater �django.utils.safestringr
�django.views.decorators.csrfr r"