o
    e                     @   s   d dl Z 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
 d dlmZ dd	lmZmZmZ d
Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd ZG dd deZdS )    N)HttpResponse)	get_token)render)loader)format_html)View   )PostUploadProjectz!https://storage.benotx.one/media/c                 C   $   t d}dtd}t||| S )Nzhome/index.html r   media_custom_endpointr   get_templater   r   r   requesttemplatecontext r   &/var/www/html/benotx_one/home/views.pyindex   
   
r   c                 C   s.   t j }td}|td}t||| S )Nzhome/posts.html)postsr   )r	   objectsallr   r   r   r   r   )r   r   r   r   r   r   r   r      s   

r   c                 C   r   )Nhome/privacy_policy.htmlr   r   r   r   r   r   r   privacy_policy%   r   r   c                 C   2   t jj|d}td}|td}t||| S )Nidzhome/post.html)postr   )r	   r   getr   r   r   r   r   )r   r!   r"   r   r   r   r   r   get_post.      
r$   c                 C   r   )Nzhome/profile.htmlr   r   r   r   r   r   r   get_profile:   r   r&   c                 C   s"   t d}ddi}t||| S )Nr   r   )r   r   r   r   r   r   r   r   	get_aboutC   s   
r'   c                 C   s.   t j }|td}td}t||| S )N)projectsr   zhome/projects.html)r   r   r   r   r   r   r   r   )r   r(   r   r   r   r   r   get_projectsK   s   

r)   c                 C   r   )Nr    zhome/project.html)projectr   )r   r   r#   r   r   r   r   r   )r   r!   r*   r   r   r   r   r   get_projectT   r%   r+   c                   @   s   e Zd Zdd Zdd ZdS )
UploadViewc                 C   s   dt | }t|S )NaM  
                <form method="post" enctype="multipart/form-data">
                  <input type='text' style='display:none;' value='%s' name='csrfmiddlewaretoken'/>
                  <input type="file" name="image" accept="image/*">
                  <button type="submit">Upload Image</button>
                </form>
            )r   r   )selfr   htmlr   r   r   r#   `   s   zUploadView.getc                 C   s$   |j d }t||j}td| S )Nimagez<img src='%s'/>)FILESr
   upload_imagenamer   )r-   r   r/   Z
public_urir   r   r   r"   j   s   
zUploadView.postN)__name__
__module____qualname__r#   r"   r   r   r   r   r,   _   s    
r,   )r.   django.httpr   django.middleware.csrfr   Zdjango.shortcutsr   django.templater   django.utils.htmlr   django.viewsr   modelsr	   r
   r   r   r   r   r   r$   r&   r'   r)   r+   r,   r   r   r   r   <module>   s$    				