B
    b                 @   s   d dl mZ d dlZd dlmZ d dlmZ G dd dejZ	G dd dej
ZG d	d
 d
ej
ZG dd dej
ZG dd dej
ZdS )    )gettext_lazyN)admin)formsc               @   s   e Zd ZejedddZdS )PushNotificationFormZappNotice_field_contentT)labelrequiredN)__name__
__module____qualname__r   Z	TextField_content r   r   >G:\easytimepro\master/mysite/mobile\actions\applist_actions.pyr   	   s   r   c               @   s8   e Zd ZdZdZedZedZedZe	Z
dd ZdS )	PushNotificationz
    Push Notification
    TZmobile_action_pushNotificationZ%mobile_action_pushNotificationHelpTxtZ)mobile_action_pushNotificationDescriptionc             O   s  | j }|d }ddlm} dd l}d}d}x|D ]}	|	jsFttd|	j|krddlm	}
 ddl
m} |j|jd	}|j|d
}|	j}||ddd}d}|
|ddd}tdddg}|||dg}|j||d q0|	j|kr0d}ddlm} ||d}d}|j|	j||d}q0W d S )Nr   r   )settings      zDevice token not found.)
APNsClient)PayloadZapp_certzproduction.pemdefault)ZalertZsoundZbadgezcom.easytimepro.zktecoF)Zuse_sandboxZuse_alternative_portNotificationtokenpayload)r   r   )notificationstopiczAAAACibfadM:APA91bH8bWU9Tf06kvajaa2a8n9dV5Mnpx6hv2YUf0gccvd43bIzrihmleHJgDDQv-zAv2l8oqM0MiAWqepLl29N9suOV2k23VM3cOsgQ4gqUjo37MycpmcvdPx-da69KnQZqTm8deSq)FCMNotification)Zapi_key)Zregistration_idZmessage_titleZmessage_body)objectsZdjango.confr   osZdevice_token	Exceptionr   Zclient_categoryZapns2.clientr   Zapns2.payloadr   pathjoinZADDITION_FILE_ROOTcollections
namedtupleZsend_notification_batchZpyfcmr   Znotify_single_device)selfargskwargsr   Znotificationr   r   ZIOSZANDROIDobjr   r   ZctfcZpemZ	token_hexmsgr   Zclientr   r   ZANDROID_SERVER_KEYr   Zpush_servicetitleresultr   r   r   action   s:    



zPushNotification.actionN)r   r	   r
   __doc__batch_selectr   verbose_name	help_textshort_descriptionr   Zaction_formr*   r   r   r   r   r      s   r   c               @   s8   e Zd ZdZdZedZeZedZedZ	dd Z
dS )ForceOfflinez
    Force Offline
    TZapplist_action_forceOfflinezforce_offline_confirm {0} {1}c             O   s&   | j }x|D ]}d|_|  qW d S )Nr   )r   Zactivesave)r#   r$   r%   r   r&   r   r   r   r*   D   s    
zForceOffline.actionN)r   r	   r
   r+   r,   r   r-   r/   r.   confirmationr*   r   r   r   r   r0   :   s   r0   c               @   s8   e Zd ZdZdZedZeZedZedZ	dd Z
dS )Disablez
    Disable Client
    TZapplist_action_disablez#app_account_disable_confirm {0} {1}c             O   s&   | j }x|D ]}d|_|  qW d S )Nr   )r   enabler1   )r#   r$   r%   r   r&   r   r   r   r*   U   s    
zDisable.actionN)r   r	   r
   r+   r,   r   r-   r/   r.   r2   r*   r   r   r   r   r3   K   s   r3   c               @   s8   e Zd ZdZdZedZeZedZedZ	dd Z
dS )Enablez
    Enable Client
    TZapplist_action_enablez"app_account_enable_confirm {0} {1}c             O   s&   | j }x|D ]}d|_|  qW d S )Nr   )r   r4   r1   )r#   r$   r%   r   r&   r   r   r   r*   f   s    
zEnable.actionN)r   r	   r
   r+   r,   r   r-   r/   r.   r2   r*   r   r   r   r   r5   \   s   r5   )Zdjango.utils.translationr   r   r!   mysiter   Zmysite.adminr   ZZKActionFormr   ZZKModelActionr   r0   r3   r5   r   r   r   r   <module>   s   -