ó
0;Xc           @   s°   d  d l  m  Z  d  d l Z d  d l m Z 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	 „  Z d
 „  Z d „  Z d „  Z d S(   iÿÿÿÿ(   t   datetimeN(   t   render_to_responset   rendert   redirect(   t   HttpResponse(   t   reverse(   t   LldevicePdlagAlarm(   t   user_get_language(   t   notification_return_listc         C   sO  |  j  j ƒ  r;|  j j d ƒ } t j |  j j d ƒ d ƒ } t j |  j j d ƒ d ƒ } t j j d | d | d | ƒ } d } d } | d	 7} | d
 7} x† | D]~ } | j	 d  k rð | d | j j | ƒ d 7} | d | j d 7} q¥ | d | j j | ƒ d 7} | d | j d 7} q¥ W| d 7} t | ƒ St t d ƒ ƒ Sd  S(   Nt	   device_idt   startDateInputs   %Y-%m-%d %H:%M:%St   endDateInputt   timestamp__gtet   timestamp__ltet   lldevicelistsª   <button style="margin-right: 20px; margin-top:-40px; color: #000000; font-size: 30px" type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>sO   <div style="margin-top: 50px;"><table class="table table-striped" id="tblGrid">s†   <thead id="tblHead"><tr><th><font color="#444444">Timestamp</font></th><th><font color="#444444">Alarm</font></th></tr></thead><tbody>s   <tr><td><font color="#444444">s   </font></td>s   <td><font color="#444444">s   </font</td></tr>s   </tbody></table></div>t
   login_page(   t   usert   is_authenticatedt   GETt   getR    t   strptimeR   t   objectst   filtert   checkedt   Nonet	   timestampt   strftimet   alarmR   R   R   (   t   requestR	   t
   start_datet   end_datet
   alarm_listt   fmtt   htmlR   (    (    sC   /var/www/html/leakless-monitor/Applications/Measure/Alarms/views.pyt   alarm_return_device_alarms   s$    !



c         C   s   |  j  j ƒ  rk y9 t j j d |  j j d ƒ ƒ j d d ƒ t d ƒ SWq{ t	 k
 rg } t | j
 ƒ SXn t t d ƒ ƒ Sd  S(   Nt   idlldevicepdlag_alarmt   AlarmIDR   i   s   Alarm confirmedR   (   R   R   R   R   R   R   R   t   updateR   t	   Exceptiont   messageR   R   (   R   t   e(    (    sC   /var/www/html/leakless-monitor/Applications/Measure/Alarms/views.pyt   alarm_confirm(   s    +c   	      C   s~  |  j  j ƒ  rjg  } |  j  j ƒ  } x( | D]  } | j | j d ƒ d ƒ q+ Wt j j d | d t ƒ j	 d ƒ } d } d } d } x | D]• } | d	 k r¢ Pn  | d 7} | d
 t
 | j ƒ d t
 | j ƒ d | j j | ƒ d t
 | j ƒ d t j | j ƒ j d d ƒ d d 7} qŒ W| d 7} | d k rVd t
 | ƒ d | } n
 d | } t | ƒ St t d ƒ ƒ Sd  S(   Nt   .i   t   lldevicelist__int   checked__isnulls
   -timestamps   %Y-%m-%d %H:%M:%Si    sl   <ul id="notifDropDown" class="dropdown-menu scrollable-menu" style="background-color: #3399cc;" role="menu">i
   s   <li id="alarms    "><a><div><font color="#ffffff">s	   , &#160; s:   &#160; &#160; <button type="button" onclick="confirmAlarm(sC   )" class="btn btn-default">Confirm</button><br><div align="center">t   ,s   <br>s   </div>&#160;s   </font></div></a></li>s   </ul>sE   <span id="redNotifier" value="fire_Alarm" class="badge badge-notify">s   </span>s9   <span id="redNotifier" class="badge badge-notify"></span>R   (   R   R   t   get_all_permissionst   appendt   splitR   R   R   t   Truet   order_byt   strR#   R   R   R   t   cgit   escapeR   t   replaceR   R   R   (	   R   t	   permfieldt   permissionst   permR   R    t   counterR!   R   (    (    sC   /var/www/html/leakless-monitor/Applications/Measure/Alarms/views.pyt    alarm_return_alarm_notifications3   s,    	
v


c         C   s¶   |  j  j ƒ  r¢ g  } |  j  j ƒ  } x( | D]  } | j | j d ƒ d ƒ q+ Wt |  ƒ } t j j d | ƒ } t	 d i |  j  d 6| d 6| d 6t
 |  ƒ d 6ƒ St t d	 ƒ ƒ Sd  S(
   NR*   i   R+   s   alarms.htmlt   user_objectt   alarmst   notification_listt   langR   (   R   R   R.   R/   R0   R   R   R   R   R   R   R   R   (   R   R7   R8   R9   R>   R   (    (    sC   /var/www/html/leakless-monitor/Applications/Measure/Alarms/views.pyt   alarm_return_alarm_tableS   s    (   R    R4   t   django.shortcutsR   R   R   t   django.httpR   t   django.core.urlresolversR   t   Applications.Measure.modelsR   t   Applications.Users.viewsR   t    Applications.Notifications.viewsR   R"   R)   R;   R@   (    (    (    sC   /var/www/html/leakless-monitor/Applications/Measure/Alarms/views.pyt   <module>   s   			 