ó
O'—^c           @  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
 d d l m Z e d e j f d	 „  ƒ  Yƒ Z d
 e j f d „  ƒ  YZ d e j j f d „  ƒ  YZ d e f d „  ƒ  YZ d e j f d „  ƒ  YZ d e j j f d „  ƒ  YZ d e f d „  ƒ  YZ d „  Z d S(   iÿÿÿÿ(   t   unicode_literals(   t   settings(   t   models(   t   python_2_unicode_compatible(   t   ugettext_lazyi   (   t   HexIntegerFieldt   Devicec        	   B  sº   e  Z e j d  d d e d ƒ d e d e ƒ Z e j d e d ƒ d e d e d	 ƒ ƒ Z e j	 e
 j d e d e ƒZ e j d e d
 ƒ d e d e ƒ Z d d d „  ƒ  YZ d „  Z RS(   t
   max_lengthiÿ   t   verbose_nameu   Namet   blankt   nullu	   Is activet   defaultt	   help_textu/   Inactive devices will not be sent notificationsu   Creation datet   auto_now_addt   Metac           B  s   e  Z e Z RS(    (   t   __name__t
   __module__t   Truet   abstract(    (    (    s;   /tmp/pip-unpacked-wheel-MTFMX_/push_notifications/models.pyR      s   c         C  s;   |  j  p: t |  j p d ƒ p: d |  j j |  j p6 d f S(   Nu    u	   %s for %su   unknown user(   t   namet   strt	   device_idt	   __class__R   t   user(   t   self(    (    s;   /tmp/pip-unpacked-wheel-MTFMX_/push_notifications/models.pyt   __str__   s    	(    (   R   R   R   t	   CharFieldt   _R   R   t   BooleanFieldt   activet
   ForeignKeyR   t   AUTH_USER_MODELR   t   DateTimeFieldt   date_createdR   R   (    (    (    s;   /tmp/pip-unpacked-wheel-MTFMX_/push_notifications/models.pyR      s   *$t   GCMDeviceManagerc           B  s   e  Z d  „  Z RS(   c         C  s   t  |  j ƒ S(   N(   t   GCMDeviceQuerySett   model(   R   (    (    s;   /tmp/pip-unpacked-wheel-MTFMX_/push_notifications/models.pyt   get_queryset   s    (   R   R   R%   (    (    (    s;   /tmp/pip-unpacked-wheel-MTFMX_/push_notifications/models.pyR"      s   R#   c           B  s   e  Z d  „  Z RS(   c         K  s‚   |  r~ d d l  m } | j d i  ƒ } | d  k	 rA | | d <n  t |  j d t ƒ j d d t ƒƒ } | d | d	 | |  Sd  S(
   Ni   (   t   gcm_send_bulk_messageu   extrau   messageR   u   registration_idt   flatt   registration_idst   data(   t   gcmR&   t   popt   Nonet   listt   filterR   t   values_list(   R   t   messaget   kwargsR&   R)   t   reg_ids(    (    s;   /tmp/pip-unpacked-wheel-MTFMX_/push_notifications/models.pyt   send_message"   s    '(   R   R   R3   (    (    (    s;   /tmp/pip-unpacked-wheel-MTFMX_/push_notifications/models.pyR#   !   s   t	   GCMDevicec           B  sx   e  Z e d  e d ƒ d e d e d e d e d ƒ ƒ Z e j d  e d ƒ ƒ Z e	 ƒ  Z
 d d d	 „  ƒ  YZ d
 „  Z RS(   R   u	   Device IDR	   R
   t   db_indexR   u;   ANDROID_ID / TelephonyManager.getDeviceId() (always as hex)u   Registration IDR   c           B  s   e  Z e d  ƒ Z RS(   u
   GCM device(   R   R   R   R   (    (    (    s;   /tmp/pip-unpacked-wheel-MTFMX_/push_notifications/models.pyR   8   s   c         K  sT   d d l  m } | j d i  ƒ } | d  k	 r; | | d <n  | d |  j d | |  S(   Ni   (   t   gcm_send_messageu   extrau   messaget   registration_idR)   (   R*   R6   R+   R,   R7   (   R   R0   R1   R6   R)   (    (    s;   /tmp/pip-unpacked-wheel-MTFMX_/push_notifications/models.pyR3   ;   s
    (    (   R   R   R   R   R   R   R   t	   TextFieldR7   R"   t   objectsR   R3   (    (    (    s;   /tmp/pip-unpacked-wheel-MTFMX_/push_notifications/models.pyR4   .   s   $	t   APNSDeviceManagerc           B  s   e  Z d  „  Z RS(   c         C  s   t  |  j ƒ S(   N(   t   APNSDeviceQuerySetR$   (   R   (    (    s;   /tmp/pip-unpacked-wheel-MTFMX_/push_notifications/models.pyR%   D   s    (   R   R   R%   (    (    (    s;   /tmp/pip-unpacked-wheel-MTFMX_/push_notifications/models.pyR:   C   s   R;   c           B  s   e  Z d  „  Z RS(   c         K  sW   |  rS d d l  m } t |  j d t ƒ j d d t ƒƒ } | d | d | |  Sd  S(   Ni   (   t   apns_send_bulk_messageR   u   registration_idR'   R(   t   alert(   t   apnsR<   R-   R.   R   R/   (   R   R0   R1   R<   R2   (    (    s;   /tmp/pip-unpacked-wheel-MTFMX_/push_notifications/models.pyR3   I   s    '(   R   R   R3   (    (    (    s;   /tmp/pip-unpacked-wheel-MTFMX_/push_notifications/models.pyR;   H   s   t
   APNSDevicec           B  s   e  Z e j d  e d ƒ d e d e d e d d ƒ Z e j d  e d ƒ d d	 d
 e ƒ Z e	 ƒ  Z
 d d d „  ƒ  YZ d „  Z RS(   R   u	   Device IDR	   R
   R5   R   u%   UDID / UIDevice.identifierForVendor()u   Registration IDR   iÈ   t   uniqueR   c           B  s   e  Z e d  ƒ Z RS(   u   APNS device(   R   R   R   R   (    (    (    s;   /tmp/pip-unpacked-wheel-MTFMX_/push_notifications/models.pyR   W   s   c         K  s)   d d l  m } | d |  j d | |  S(   Ni   (   t   apns_send_messageR7   R=   (   R>   RA   R7   (   R   R0   R1   RA   (    (    s;   /tmp/pip-unpacked-wheel-MTFMX_/push_notifications/models.pyR3   Z   s    (    (   R   R   R   t	   UUIDFieldR   R   R   R   R7   R:   R9   R   R3   (    (    (    s;   /tmp/pip-unpacked-wheel-MTFMX_/push_notifications/models.pyR?   P   s   '	$	c          C  s   d d l  m }  |  ƒ  S(   Ni   (   t   apns_fetch_inactive_ids(   R>   RC   (   RC   (    (    s;   /tmp/pip-unpacked-wheel-MTFMX_/push_notifications/models.pyt   get_expired_tokensb   s    N(   t
   __future__R    t   django.confR   t	   django.dbR   t   django.utils.encodingR   t   django.utils.translationR   R   t   fieldsR   t   ModelR   t   ManagerR"   t   queryt   QuerySetR#   R4   R:   R;   R?   RD   (    (    (    s;   /tmp/pip-unpacked-wheel-MTFMX_/push_notifications/models.pyt   <module>   s   