ó
0;Xc           @   s|   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 „  Z d „  Z d	 S(
   iÿÿÿÿ(   t   datetime(   t   redirect(   t   HttpResponse(   t   reverse(   t   Lldevicenoatificationst   Lldevicenoatificationsack(   t   AuthUserc         C   sÕ   |  j  j ƒ  rÁ |  j j d ƒ } t d  | j d ƒ ƒ } x{ | D]s } t | ƒ } | d  k rd q@ n  t j	 j d | ƒ } t
 j	 j d |  j  j ƒ } t d | d | ƒ } | j ƒ  q@ Wt d ƒ St t d ƒ ƒ Sd  S(	   Nt   notification_idst   ,t   idlldevicenoatificationst   idt   useridt   noatificationidt   Okt
   login_page(   t   usert   is_authenticatedt   GETt   gett   filtert   Nonet   splitt   intR   t   objectsR   R
   R   t   saveR   R   R   (   t   requestR   t   notification_ids_listt   notificationt   notification_idt   notification_datat	   user_datat   notification_accept_record(    (    sB   /var/www/html/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   R   t   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(    (    sB   /var/www/html/leakless-monitor/Applications/Notifications/views.pyt   notification_return_list$   s:    


N(   R    t   django.shortcutsR   t   django.httpR   t   django.core.urlresolversR   t!   Applications.Notifications.modelsR   R   t   Applications.Users.modelsR   R    RD   (    (    (    sB   /var/www/html/leakless-monitor/Applications/Notifications/views.pyt   <module>   s   	