
    i
                     |    d dl mZ d dlmZ d dlmZ  G d dej
                        Z G d dej
                        Zy)	    )
SQLAlchemy)datetime)dbc                   $   e Zd Z ej                  ej
                  d      Z ej                   ej                  d      d      Z ej                  ej                  d      Z
 ej                   ej                  d      d      Z ej                  ej
                   ej                  d      d      Z ej                  ej                  ej                         Z ej                  ej                  ej                   ej                   	      Z ej                  ej
                  d
      Z ej                  ej
                  d
      Z ej*                  d ej,                  dd            Z ej*                  dddd      Zd Zd Zy)PostTprimary_key   Fnullable2   user.iddefault)r   onupdater   UserpostslazybackrefCommentpostzall, delete-orphan)r   r   cascadec                 "    d| j                    dS )Nz<Post >)titleselfs    D/home/kdj-ubuntu1/mlink_AI_Server/mlink-backend/./src/models/post.py__repr__zPost.__repr__   s    

|1%%    c                    | j                   | j                  | j                  | j                  | j                  | j
                  r| j
                  j                  nd | j                  r| j                  j                         nd | j                  r| j                  j                         nd | j                  | j                  t        | j                        dS )N)idr   contentcategory	author_idauthor_username
created_at
updated_atviewslikescomment_count)r$   r   r%   r&   r'   authorusernamer)   	isoformatr*   r+   r,   lencommentsr   s    r    to_dictzPost.to_dict   s    ''ZZ||7;{{t{{339=$//335d9=$//335dZZZZ /
 	
r"   N)__name__
__module____qualname__r   ColumnIntegerr$   Stringr   Textr%   r&   
ForeignKeyr'   DateTimer   utcnowr)   r*   r+   r,   relationshipr   r.   r2   r!   r3    r"   r    r   r      s1   	2::4	0BBIIibiinu5Ebii%0Gryy27H		"**mbmmI&>OI2;;@J2;;(//ZJBIIbjj!,EBIIbjj!,E R__VZRZZd-KLFry&tMabH&
r"   r   c                      e Zd Z ej                  ej
                  d      Z ej                  ej                  d      Z ej                  ej
                   ej                  d      d      Z
 ej                  ej
                   ej                  d      d      Z ej                  ej
                   ej                  d      d      Z ej                  ej                  ej                        Z ej"                  d	 ej$                  d
d            Z ej"                  d  ej$                  deg      d      Zd Zd Zy)r   Tr   Fr   zpost.idr   z
comment.idr   r   r2   r   r   parent)remote_side)r   r   c                 "    d| j                    dS )Nz	<Comment r   )r$   r   s    r    r!   zComment.__repr__2   s    477)1%%r"   c                 b   | j                   | j                  | j                  | j                  | j                  r| j                  j
                  nd | j                  | j                  r| j                  j                         nd | j                  D cg c]  }|j                          c}dS c c}w )N)r$   r%   post_idr'   r(   	parent_idr)   replies)r$   r%   rE   r'   r.   r/   rF   r)   r0   rG   r3   )r   replys     r    r3   zComment.to_dict5   s~    ''||||7;{{t{{339=$//335d59\\B\E\B	
 		
 Cs   B,N)r4   r5   r6   r   r7   r8   r$   r:   r%   r;   rE   r'   rF   r<   r   r=   r)   r>   r   r.   rG   r!   r3   r?   r"   r    r   r   &   s   	2::4	0Bbii%0Gbii

MBMM)$<uMG		"**mbmmI&>OI		"**mbmmL&ADQI2;;@J R__VZRZZ
-NOFbooiHSURV1W^bcG&

r"   r   N)flask_sqlalchemyr   r   src.models.userr   Modelr   r   r?   r"   r    <module>rL      s/    '  
288 
B
bhh 
r"   