B
    Ac                 @   sN  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 d dlmZ d dlmZ d d	lmZ G d
d deZG dd dejZee	jeddd Zee	jeddd Zdddd ddddddddd ddddddddd ddddddddd ddddddddd dddddd ddd d ddddd!ddd d!ddddgZd"S )#    )cache)	Countries)models)settings)signals)receiver)gettext_lazy)CountryField)db_constc               @   s   e Zd ZdddZdS )AllowedCountriesZIndiazUnited States of America)INZUSN)__name__
__module____qualname__Zonly r   r   :G:\easytimepro\master/mysite/cloud\models\model_feature.pyr      s   r   c               @   s   e Zd ZdZejedejdddZ	ej
ddZej
ddZejededd	Zejed
ddddZeddedZejdddZejddddZG dd dZdd ZdS )Feature))r   Server)   Customization)   	PrototypeZfeature_field_nameF)Z
max_lengthnullblankT)defaultZfeature_field_typer   )verbose_namechoicesr   Zfeature_field_description   z(select country)r   )Zblank_labelr   Z	countries)r   r      c               @   s   e Zd ZedZdZeZdS )zFeature.Metar   ZcloudN)r   r   r   _r   Z	app_labelZverbose_name_pluralr   r   r   r   Meta#   s   r    c             C   s   d | j| jjS )Nz{}/{})formatnamecountry)selfr   r   r   __str__(   s    zFeature.__str__N)r   r   r   ZTYPE_CHOICESr   Z	CharFieldr   r
   ZMAX_FEATURE_NAMEr"   ZBooleanFielddisplay_statuseffective_statusZSmallIntegerFieldtypedescriptionr	   r   r#   Z
FloatFieldpricecurrencyr    r%   r   r   r   r   r      s   r   )senderc             K   s   t jrddlm} dddd}| }|| }|rZ|j|d}	d}
||
|	d d}| }n|j}d	|}
||
d d d}| }t	d
}|d d }xP|D ]H}|d
 }||kr|t
 }|j|d}	d|}
||
|	d d}| }qW d S )Nr   )!HttpRequestInterfaceForIoTService01)r   r   r   )r"   r(   z7https://subscriptiondev.minervaiot.com/api/v1/features/)bodyparamsz?https://subscriptiondev.minervaiot.com/api/v1/features/?name={}application_iddataresultsz:https://subscriptiondev.minervaiot.com/api/v1/features/{}/)r   CLOUD_VERSION"mysite.cloud.minerva_iot_interfacer-   Zget_type_displayr"   Zpostr!   getr   idZput)r,   instanceZcreatedrawkwargsr-   Zfeature_type_mapZcurrent_feature_typeZdeveloper_portal_feature_typer0   urlinterface_objectcontentfeature_namecurrent_application_idr4   featureresult_application_id
feature_idr   r   r   .save_or_update_feature_to_subscription_service,   s:    



rD   c             K   s   t jrddlm} |j}d|}||d d d}| }td}|d d }	xD|	D ]<}
|
d }||krT|
t }d|}||d d d}|	 }qTW d S )	Nr   )r-   z?https://subscriptiondev.minervaiot.com/api/v1/features/?name={})r0   r1   r2   r3   r4   z:https://subscriptiondev.minervaiot.com/api/v1/features/{}/)
r   r5   r6   r-   r"   r!   r7   r   r8   delete)r,   r9   r;   r-   r?   r<   r=   r>   r@   r4   rA   rB   rC   r   r   r   &delete_feature_to_subscription_serviceX   s     


rF   Z
AttendanceTzAttendance moduler   g        ZINR)r"   r&   r'   r(   r)   r#   r*   r+   ZPayrollzPayroll modulezAccess controlzAccess control modulezMobile applicationzWhatsApp notificationzSMS notificationzREST APIN)Zdjango.core.cacher   Zdjango_countriesr   Z	django.dbr   Zdjango.confr   Zdjango.db.modelsr   Zdjango.dispatch.dispatcherr   Zdjango.utils.translationr   r   Zdjango_countries.fieldsr	   Zmysite.personnelr
   r   ZModelr   Z	post_saverD   Zpost_deleterF   ZDEFAULT_FEATURE_PARAMSr   r   r   r   <module>   s   ,