o
    1wcY                     @   s   d dl mZ d dlmZ d dlmZ d dlmZ d dlZd dl	m
Z
 d dlmZ d dlmZ G d	d
 d
ejZG dd dejZdS )    )default)models)RichTextField)ImageN)BytesIO)InMemoryUploadedFile)reversec                   @   s   e Zd ZejdddddZejddddejd	Zej	d
dddddZ
ejd
ddddZejdddddZejddddddZedddddZedddddZejddZejddZdd ZG d d! d!ZdS )"BlogCategory@   NzBlog Category NamezValues: Enter Category Name.)
max_lengthr   verbose_name	help_textselfTPARENTCHILDBLOG)blanknullrelated_name	on_delete   zCategory Slugz!Values: Enter Blog Category Slug.)r   uniquer   r   r   zCategory Titlez'Values: Enter Blog Category Meta Title.   zCategory Descriptionz-Values: Enter Blog Category Meta Description.   zCategory Keywordz*Values: Enter Blog Category Meta Keywords.)r   r   r   r   r   zCategory Header Contentz% Values: Blog Category Header Contentr   r   r   r   zCategory Footer Contentz% Values: Blog Category Footer Contentauto_now_addauto_nowc                 C      | j S Nnamer    r"   /var/www/jaguar/blog/models.py__str__'      zBlogCategory.__str__c                   @   s   e Zd ZdZdS )zBlogCategory.MetazBlog CategoryN)__name__
__module____qualname__verbose_name_pluralr"   r"   r"   r#   Meta*   s    r*   )r&   r'   r(   r   	CharFieldr    
ForeignKeyCASCADEparent	SlugFieldslugtitle	TextFielddescriptionkeywordr   header_contentfooter_contentDateTimeField
created_at
updated_atr$   r*   r"   r"   r"   r#   r	   
   sJ    
r	   c                       s   e Zd ZejedejddZejdddZ	ej
dddd	Zejdd
dZejdddZejdddddZedddddZejddddZejddddddZejddZejddZdd Zdd Z fdd Z  ZS )!BlogBlogCategoryPostN)r   r   r      zEnter Blog Name)r   r   TzEnter Blog Slug)r   r   r   zEnter Blog Titlei  zEnter Blog Description   zEnter Blog Keywords)r   r   r   r   zBlog OverviewzValues: Enter Blog Content.r   
blog_imagezUpload Blog Image)	upload_tor   r   r   z Values: Upload Blog Small Thumb.)r?   r   r   r   r   r   r   c                 C   r   r   r   r!   r"   r"   r#   r$   B   r%   zBlog.__str__c                 C   s   t dd| jidS )Nzblog:blogdetailr0   )kwargs)r   r0   r!   r"   r"   r#   get_absolute_urlE   s   zBlog.get_absolute_urlc                    sf   t    | jr-t| jj}|jdks|jdkr'|d}|| jj d S t	d d S t	d d S )Ni,     )iZ  i  znot find imgzNot find any images)
supersaveblog_thumbnailr   openpathwidthheightresizeprint)r   	thump_img	__class__r"   r#   rD   H   s   

z	Blog.save)r&   r'   r(   r   r,   r	   r-   categoryr+   r    r/   r0   r1   r2   r3   r4   r   overview
ImageFieldr>   rE   r7   r8   r9   r$   rA   rD   __classcell__r"   r"   rM   r#   r:   -   s0    r:   )email.policyr   	django.dbr   ckeditor.fieldsr   PILr   sysior   django.core.files.uploadedfiler   django.urlsr   Modelr	   r:   r"   r"   r"   r#   <module>   s    #