Ë
    º2Úiþ  ã                   óÞ  — d 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 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 ddlmZ ddlmZ  edd«      Z e e«       «       ed«      k\  rddlm Z  nddl!Z!ddlm"Z" d„ Z#d„ Z  G d„ de«      Z$ G d„ de$«      Z% G d„ de$«      Z&ed„ «       Z'ed%d„«       Z(ed%d„«       Z)ed%d „«       Z*ed!„ «       Z+ed"„ «       Z,ed#„ «       Z-d$„ Z.y)&z$ Django Notifications example views é    )ÚStrictVersion)Úget_version)Úsettings)Úlogin_required)Úget_object_or_404Úredirect)Úmethod_decorator)Ú
iri_to_uri)Úurl_has_allowed_host_and_scheme)Únever_cache)ÚListView)Ú
load_model)Úget_notification_list)Úslug2idÚnotificationsÚNotificationz1.7.0)ÚJsonResponseN)ÚHttpResponsec                 ó>   — t        | d«      r| j                  «       S | S )NÚ	isoformat)Úhasattrr   )Úobjs    úJ/var/www/html/acx/venv/lib/python3.12/site-packages/notifications/views.pyÚdate_handlerr      s   € Ü")¨#¨{Ô";ˆs�}‰}‹ÐDÀÐDó    c                 óN   — t        t        j                  | t        ¬«      d¬«      S )N)Údefaultzapplication/json)Úcontent_type)r   ÚjsonÚdumpsr   )Údatas    r   r   r   "   s    € ÜÜ�J‰J�t¤\Ô2Ø+ô-ð 	-r   c                   ód   ‡ — e Zd ZdZdZ ej                  «       d   Z ee	«      ˆ fd„«       Z
ˆ xZS )ÚNotificationViewListznotifications/list.htmlr   ÚPAGINATE_BYc                 ó2   •— t        t        | �
  |g|¢­i |¤ŽS ©N)Úsuperr#   Údispatch)ÚselfÚrequestÚargsÚkwargsÚ	__class__s       €r   r(   zNotificationViewList.dispatch-   s+   ø€ äÔ)¨4Ñ9Øð&Øò&Ø$ñ&ð 	&r   )Ú__name__Ú
__module__Ú__qualname__Útemplate_nameÚcontext_object_nameÚnotification_settingsÚ
get_configÚpaginate_byr	   r   r(   Ú__classcell__)r-   s   @r   r#   r#   (   s;   ø„ Ø-€MØ)ÐØ2Ð'×2Ñ2Ó4°]ÑC€Ká�nÓ%ó&ó &ô&r   r#   c                   ó   — e Zd ZdZd„ Zy)ÚAllNotificationsListz+
    Index page for authenticated user
    c                 óð   — t        j                  «       d   r0| j                  j                  j                  j                  «       }|S | j                  j                  j                  j                  «       }|S )NÚSOFT_DELETE)r3   r4   r*   Úuserr   ÚactiveÚall)r)   Úqsets     r   Úget_querysetz!AllNotificationsList.get_queryset8   s]   € Ü ×+Ñ+Ó-¨mÒ<Ø—<‘<×$Ñ$×2Ñ2×9Ñ9Ó;ˆDð ˆð —<‘<×$Ñ$×2Ñ2×6Ñ6Ó8ˆDØˆr   N)r.   r/   r0   Ú__doc__r?   © r   r   r8   r8   3   s   „ ñór   r8   c                   ó   — e Zd Zd„ Zy)ÚUnreadNotificationsListc                 ó^   — | j                   j                  j                  j                  «       S r&   )r*   r;   r   Úunread)r)   s    r   r?   z$UnreadNotificationsList.get_querysetB   s!   € Ø�|‰|× Ñ ×.Ñ.×5Ñ5Ó7Ð7r   N)r.   r/   r0   r?   rA   r   r   rC   rC   @   s   „ ó8r   rC   c                 óö   — | j                   j                  j                  «        | j                  j	                  d«      }|r.t        |t        j                  «      rt        t        |«      «      S t        d«      S )NÚnextúnotifications:unread)
r;   r   Úmark_all_as_readÚGETÚgetr   r   ÚALLOWED_HOSTSr   r
   )r*   Ú_nexts     r   rI   rI   F   sY   € à‡L�L×Ñ×/Ñ/Ô1à�K‰K�O‰O˜FÓ#€EáÔ0°¼×8NÑ8NÔOÜœ
 5Ó)Ó*Ð*ÜÐ*Ó+Ð+r   c                 ó  — t        |«      }t        t        | j                  |¬«      }|j	                  «        | j
                  j                  d«      }|r.t        |t        j                  «      rt        t        |«      «      S t        d«      S ©N©Ú	recipientÚidrG   rH   )r   r   r   r;   Úmark_as_readrJ   rK   r   r   rL   r   r
   ©r*   ÚslugÚnotification_idÚnotificationrM   s        r   rS   rS   Q   sn   € ä˜d“m€Oä$Ü §¡°ôB€Là×ÑÔà�K‰K�O‰O˜FÓ#€EáÔ0°¼×8NÑ8NÔOÜœ
 5Ó)Ó*Ð*äÐ*Ó+Ð+r   c                 ó  — t        |«      }t        t        | j                  |¬«      }|j	                  «        | j
                  j                  d«      }|r.t        |t        j                  «      rt        t        |«      «      S t        d«      S rO   )r   r   r   r;   Úmark_as_unreadrJ   rK   r   r   rL   r   r
   rT   s        r   rY   rY   a   sn   € ä˜d“m€Oä$Ü §¡°ôB€Là×ÑÔ!à�K‰K�O‰O˜FÓ#€EáÔ0°¼×8NÑ8NÔOÜœ
 5Ó)Ó*Ð*äÐ*Ó+Ð+r   c                 óz  — t        |«      }t        t        | j                  |¬«      }t	        j
                  «       d   rd|_        |j                  «        n|j                  «        | j                  j                  d«      }|r.t        |t        j                  «      rt        t        |«      «      S t        d«      S )NrP   r:   TrG   znotifications:all)r   r   r   r;   r3   r4   ÚdeletedÚsaveÚdeleterJ   rK   r   r   rL   r   r
   rT   s        r   r]   r]   q   s•   € ä˜d“m€Oä$Ü §¡°ôB€Lô ×'Ñ'Ó)¨-Ò8Ø#ˆÔØ×ÑÕà×ÑÔà�K‰K�O‰O˜FÓ#€EáÔ0°¼×8NÑ8NÔOÜœ
 5Ó)Ó*Ð*äÐ'Ó(Ð(r   c                 ó"  — 	 | j                   j                  «       }|sddi}t        |«      S d| j                   j                  j	                  «       j                  «       i}t        |«      S # t        $ r | j                   j                  }Y Œqw xY w)NÚunread_countr   )r;   Úis_authenticatedÚ	TypeErrorr   rE   Úcountr   ©r*   Úuser_is_authenticatedr!   s      r   Úlive_unread_notification_countre   †   s�   € ð>Ø '§¡× =Ñ =Ó ?Ðñ !à˜Að
ˆô ˜ÓÐð ˜GŸL™L×6Ñ6×=Ñ=Ó?×EÑEÓGð
ˆô ˜ÓÐøô ò >Ø '§¡× =Ñ =Òð>ús   ‚A, Á,BÂBc                 ó>  — 	 | j                   j                  «       }|sdg dœ}t        |«      S t	        | d«      }| j                   j
                  j                  «       j                  «       |dœ}t        |«      S # t        $ r | j                   j                  }Y Œw xY w)ú/ Return a json with a unread notification list r   )r_   Úunread_listrE   )r;   r`   ra   r   r   r   rE   rb   )r*   rd   r!   rh   s       r   Úlive_unread_notification_listri   ˜   sž   € ð>Ø '§¡× =Ñ =Ó ?Ðñ !àØñ
ˆô ˜DÓ!Ð!ä'¨°Ó:€Kð  Ÿ™×2Ñ2×9Ñ9Ó;×AÑAÓCØ"ñ€Dô ˜ÓÐøô! ò >Ø '§¡× =Ñ =Òð>ús   ‚A: Á:BÂBc                 ó   — 	 | j                   j                  «       }|sdg dœ}t        |«      S t	        | «      }| j                   j
                  j                  «       |dœ}t        |«      S # t        $ r | j                   j                  }Y Œpw xY w)rg   r   )Ú	all_countÚall_list)r;   r`   ra   r   r   r   rb   )r*   rd   r!   rl   s       r   Úlive_all_notification_listrm   °   s“   € ð>Ø '§¡× =Ñ =Ó ?Ðñ !àØñ
ˆô ˜DÓ!Ð!ä$ WÓ-€Hð —\‘\×/Ñ/×5Ñ5Ó7Øñ€Dô ˜ÓÐøô! ò >Ø '§¡× =Ñ =Òð>ús   ‚A+ Á+BÂBc                 ó  — 	 | j                   j                  «       }|sddi}t        |«      S d| j                   j                  j	                  «       i}t        |«      S # t        $ r | j                   j                  }Y Œcw xY w)Nrk   r   )r;   r`   ra   r   rb   r   rc   s      r   Úlive_all_notification_countro   È   s‡   € ð>Ø '§¡× =Ñ =Ó ?Ðñ !à˜ð
ˆô ˜ÓÐð ˜Ÿ™×3Ñ3×9Ñ9Ó;ð
ˆô ˜ÓÐøô ò >Ø '§¡× =Ñ =Òð>ús   ‚A ÁB Á?B r&   )/r@   Údistutils.versionr   Údjangor   Údjango.confr   Údjango.contrib.auth.decoratorsr   Údjango.shortcutsr   r   Údjango.utils.decoratorsr	   Údjango.utils.encodingr
   Údjango.utils.httpr   Údjango.views.decorators.cacher   Údjango.views.genericr   Úswapperr   r   r3   Únotifications.helpersr   Únotifications.utilsr   r   Údjango.httpr   r   r   r   r#   r8   rC   rI   rS   rY   r]   re   ri   rm   ro   rA   r   r   ú<module>r~      s#  ðá *õõ Ý  Ý 9ß 8Ý 4Ý ,Ý =Ý 5Ý )Ý å ;Ý 7Ý 'á˜/¨>Ó:€á‘“Ó¡=°Ó#9Ò9Þ(ó å(òEò-ô&˜8ô &ô
Ð/ô 
ô8Ð2ô 8ð ñ,ó ð,ð ò,ó ð,ð ò,ó ð,ð ò)ó ð)ð( ñó ðð" ñó ðð. ñó ðó.r   