
    VhL	                         d dl mZ d dlmZ d dlmZmZ  G d dej                        Z G d dej                        Z	 G d d	ej                        Z
 G d
 dej                        Zy)    )models)CKEditor5Field)urlparseparse_qsc                        e Zd Z ej                  d      Z ej                  dd      Z eddd	      Z	 ej                  dd
      Zd Z fdZ xZS )
CoachStoryd   
max_lengthzrestaurant_default.jpgrestaurant_images)default	upload_toStoryr   T)config_nameblank)uniquer   c                     | j                   S N)
coach_nameselfs    ,/var/www/html/grow-django/grow/app/models.py__str__zCoachStory.__str__   s        c                 p    | j                   st        | j                        | _         t        |   |i | y r   )slugslugifycoach_namenamesupersave)r   argskwargs	__class__s      r   r    zCoachStory.save   s-    yy 3 34DId%f%r   )__name__
__module____qualname__r   	CharFieldr   
ImageField	coach_imgr   story	SlugFieldr   r   r    __classcell__)r#   s   @r   r   r      s\    !!!S1J!!!*BM`aI7	FE64t4D& &r   r   c                   `    e Zd Z ej                  dd      Z ej                  d      Zd Zy)VideoCategoryr	   T)r   r   )r   c                     | j                   S r   namer   s    r   r   zVideoCategory.__str__       yyr   N)	r$   r%   r&   r   r'   r1   r+   r   r    r   r   r.   r.      s-    6s48D64(Dr   r.   c                   `    e Zd Z ej                  d      Z ej                  ed      Zd Z	y)Authorr	   r
   authors)related_namec                     | j                   S r   r0   r   s    r   r   zAuthor.__str__#   r2   r   N)
r$   r%   r&   r   r'   r1   ManyToManyFieldr.   
categoriesr   r3   r   r   r5   r5      s-    6s+D'''INJr   r5   c                   0   e Zd Z ej                  dd      Z ej                         Z ej                  e	ej                  d      Z ej                  eej                  d      Z ej                  d      Z ej                   d	      Zd
 Zd Zd Zy)Video   zUntitled Video)r   r   videos)	on_deleter7   T)auto_now_addF)r   c                     | j                   S r   )titler   s    r   r   zVideo.__str__.   s    zzr   c                    t        | j                        }d|j                  v r:t        |j                        j                  d      }|rd|d    S | j                  S d|j                  v rd|j                   S | j                  S )Nzyoutube.comvzhttps://www.youtube.com/embed/r   zyoutu.bezhttps://www.youtube.com/embed)r   youtube_urlnetlocr   querygetpath)r   
parsed_urlvideo_ids      r   get_youtube_embed_urlzVideo.get_youtube_embed_url1   s    d../
J---
 0 0155c:H7}EE  :,,,2:??2CDDr   c                     | j                   rd| j                  rW| j                   j                  j                  | j                  j                        j                         sddlm}  |d      y y y )N)idr   )ValidationErrorz1Selected author is not assigned to this category.)authorcategoryr:   filterrN   existsdjango.core.exceptionsrO   )r   rO   s     r   cleanzVideo.clean;   sX    ;;4==1G1G1N1NRVR_R_RbRb1N1c1j1j1l>!"UVV 2m=;r   N)r$   r%   r&   r   r'   rB   URLFieldrE   
ForeignKeyr.   CASCADErQ   r5   rP   DateTimeFieldadded_onBooleanFieldfeaturedr   rL   rU   r3   r   r   r<   r<   '   s    F5EFE!&//#K v  &..W_`HVvhWF#v##6H"v""51H Wr   r<   N)	django.dbr   django_ckeditor_5.fieldsr   urllib.parser   r   Modelr   r.   r5   r<   r3   r   r   <module>ra      sP     3 +& &"FLL V\\ WFLL Wr   