
    6]hH                         d dl mZ d dl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 G d dej                        Z	y)    )models)timezonec                       e Zd ZdZ ej
                  dd      Z ej                  d      Z ej
                  dd      Z	 G d	 d
      Z
d Zy)NotificationCategoryz/Categories for different types of notificationsd   T
max_lengthuniqueblank   z#61b239)r	   defaultc                       e Zd ZdZdgZy)NotificationCategory.MetazNotification CategoriesnameN)__name__
__module____qualname__verbose_name_pluralordering     )/var/www/apihucms/notifications/models.pyMetar      s    78r   r   c                     | j                   S Nr   selfs    r   __str__zNotificationCategory.__str__       yyr   N)r   r   r   __doc__r   	CharFieldr   	TextFielddescription
color_coder   r    r   r   r   r   r      sN    96s48D"&"".K!!!Q	BJ r   r   c                       e Zd ZdZg dZ ej                  d      Z ej                  d      Z	 ej                  d      Z
 ej                  ej                  	      Z ej                  d
      Z ej                  d      Z ej"                  eej&                  ddd      Z ej                  ded      Z ej,                  d	      Z ej,                  dd      Z ej2                  dd      Z ej6                  ddd      Z ej:                  ddd      Z ej                  dd      Z G d d      Z  fdZ!d Z"e#d        Z$ xZ%S ) NotificationzMain notification model))lowLow)mediumMedium)highHigh)urgentUrgent   r	   Tr   zFull notification content)	help_textr   )auto_now_add)auto_nownotifications)	on_deletenullr   related_name
   r+   )r	   choicesr   Fz%Show in featured/highlighted sections)r   r3   zExternal link for more details)r   r3   znotifications/attachments/)	upload_tor   r9   )r	   r
   r      )r	   r   c                       e Zd ZddgZ ej
                  dg       ej
                  dg       ej
                  dg       ej
                  dg      gZy)Notification.Metaz-published_datez-created_at)fields	is_activeis_featuredcategoryN)r   r   r   r   r   Indexindexesr   r   r   r   r@   9   sU    %}5FLL!2 34FLL.FLL0FLL-	
r   r   c                    | j                   sddlm}  || j                        }|| _         d}t        j
                  j                  | j                         j                         rJ| d| | _         |dz  }t        j
                  j                  | j                         j                         rJt        | $  |i | y )Nr   )slugify   )slug-)
rJ   django.utils.textrH   titler(   objectsfilterexistssupersave)r   argskwargsrH   	base_slugcounter	__class__s         r   rR   zNotification.saveB   s    yy1

+I!DIG&&--499-=DDF(k7)4	1 &&--499-=DDF 	d%f%r   c                     | j                   S r   )rM   r   s    r   r    zNotification.__str__M   s    zzr   c                 
   | j                   j                  d      | j                   j                  d      | j                   j                  d      | j                   j                  d      | j                   j                         dS )z#Returns formatted date for frontendz%dz%Bz%Yz%Y-%m-%d)daymonthyear	full_dateiso_date)published_datestrftime	isoformatr   s    r   formatted_datezNotification.formatted_dateP   sp     &&//5((11$7''006,,55jA++557
 	
r   )&r   r   r   r"   PRIORITY_CHOICESr   r#   rM   r$   r%   contentDateTimeFieldr   nowr_   
created_at
updated_at
ForeignKeyr   SET_NULLrD   priorityBooleanFieldrB   rC   URLFieldexternal_link	FileField
attachment	SlugFieldrJ   meta_descriptionr   rR   r    propertyrb   __classcell__)rW   s   @r   r(   r(      sn   ! F,E"&"".Kf)DEG *V))(,,?N%%%48J%%%t4J !v  //$H  v27GQYZH###D1I%&%%e?fgK $FOO$:Z[M!!!,HPT[_`J 6s4tDD'v''3dC
 
	& 
 
r   r(   c                   R    e Zd ZdZ ej
                  dd      Z G d d      Zd Zy)	NotificationTagzTags for notifications2   Tr   c                       e Zd ZdgZy)NotificationTag.Metar   Nr   r   r   r   r   r   r   r   ry   `   s	    8r   r   c                     | j                   S r   r   r   s    r   r    zNotificationTag.__str__c   r!   r   N)	r   r   r   r"   r   r#   r   r   r    r   r   r   rv   rv   \   s(     6r$7D r   rv   c                       e Zd ZdZ ej
                  eej                  d      Z ej
                  e	ej                  d      Z
 G d d      Zd Zy)	NotificationTagRelationz8Many-to-many relationship between notifications and tagsnotification_tags)r8   r:   tagged_notificationsc                       e Zd ZddgZy)NotificationTagRelation.MetanotificationtagN)r   r   r   unique_togetherr   r   r   r   r   l   s    )51r   r   c                 `    | j                   j                   d| j                  j                   S )Nz - )r   rM   r   r   r   s    r   r    zNotificationTagRelation.__str__o   s(    ##))*#dhhmm_==r   N)r   r   r   r"   r   ri   r(   CASCADEr   rv   r   r   r    r   r   r   r}   r}   g   sJ    B$6$$\V^^ZmnL
&

Ov~~Tj
kC2 2>r   r}   c                      e Zd ZdZ ej
                  dd      Z ej
                  d      Z ej                         Z	 ej
                  ddd	      Z
 ej                  d
      Z ej                  d      Z G d d      Zd Zy)SiteStatisticz,Statistics displayed alongside notificationsr   Tr      r2   rw   zIcon class or name)r	   r   r3   r   r4   c                       e Zd ZddgZy)SiteStatistic.Metaorderr   Nrz   r   r   r   r   r   |   s    V$r   r   c                 8    | j                    d| j                   S )Nz: )r   valuer   s    r   r    zSiteStatistic.__str__   s    ))Btzzl++r   N)r   r   r   r"   r   r#   r   r   r$   r%   iconPositiveIntegerFieldr   rl   rB   r   r    r   r   r   r   r   s   s    66s48DF+E"&""$K6rAUVD'F''2E###D1I% %,r   r   N)
	django.dbr   django.utilsr   Modelr   r(   rv   r}   r   r   r   r   <module>r      s^     !6<< F
6<< F
Rfll 	>fll 	>,FLL ,r   