ó
ûA&Xc           @   sl   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   Z
 d   Z d S(	   iĸĸĸĸ(   t   datetime(   t   redirect(   t   HttpResponse(   t   Lldevicenoatificationst   Lldevicenoatificationsack(   t   AuthUserc         C   s   |  j  j   r |  j j d  } x] | D]U } t j j d |  } t j j d |  j  j  } t d | d |  } | j	   q( Wt
 d  St d  Sd  S(   Nt   noatification_idst   idlldevicenoatificationst   idt   useridt   noatificationidt   Oks   /leakless-monitor(   t   usert   is_authenticatedt   GETt   getR   t   objectsR   R   R   t   saveR   R   (   t   requestt   notification_idst   notificationt   notification_datat	   user_datat   notification_accept_record(    (    sf   D:\SMTech Code\LeakLess Software\LeakLess Monitor\LeakLess Monitor\Applications\Notifications\views.pyt   notification_accept   s    
c         C   sl  |  j  j } |  j j d d  } t j   } t j j d |  } | j	 d d t
 } t j j d |  } | j d |  } g  } g  }	 xĮ | D]ŋ }
 i |
 j d 6|
 j d	 6|
 j d
 6} | d k rņ |
 j | d <|
 j | d <|
 j | d <n6 | d k r'|
 j | d <|
 j | d <|
 j | d <n  |	 j |  |
 | k r | j |  q q Wi | d 6|	 d 6} | S(   Nt   langs   en-gbR	   R
   t   flatt   expirationdate__gtet   idlldevicenoatifications__inR   t   typet   icont   hrt   textt   titlet   headert   not_acknowledgedt   all(   R   R   t   sessionR   R    t   nowR   R   t   filtert   values_listt   TrueR   t   excludeR   R   R   t   text_hrt   title_hrt	   header_hrt   text_ent   title_ent	   header_ent   append(   R   t   user_idt   language_stringt   current_datet   notifications_acknowledgedt   notifications_acknowledged_listt   notification_data_allt   notification_data_excludedt*   return_data_notifications_not_acknowledgedt   return_data_notifications_allR   t   notification_infot   return_data(    (    sf   D:\SMTech Code\LeakLess Software\LeakLess Monitor\LeakLess Monitor\Applications\Notifications\views.pyt   notification_return_list   s:    


N(   R    t   django.shortcutsR   t   django.httpR   t!   Applications.Notifications.modelsR   R   t   Applications.Users.modelsR   R   R=   (    (    (    sf   D:\SMTech Code\LeakLess Software\LeakLess Monitor\LeakLess Monitor\Applications\Notifications\views.pyt   <module>   s   	