
    =
j!                        d dl mZ d dlmZ  G d dej                        Z G d dej                        Z G d dej                        Z G d	 d
ej                        Z G d dej                        Z	 G d dej                        Z
 G d dej                        Z G d dej                        Z G d dej                        Z G d dej                        Z G d dej                        Z G d dej                        Zy)    )models)Userc                   t    e Zd Z ej                  dd      Z ej                  d      Z G d d      Zd Zy	)
IstatGuestType   T
max_lengthprimary_key@   r	   c                       e Zd ZdZdgZy)IstatGuestType.Metaistat_guest_typecodeN__name__
__module____qualname__db_tableordering     /backend/istat/models.pyMetar   	   s    %8r   r   c                 8    | j                    d| j                   S Nz - r   descriptionselfs    r   __str__zIstatGuestType.__str__       ))C 0 0122r   N	r   r   r   r   	CharFieldr   r   r   r!   r   r   r   r   r      s7    6qd;D"&""b1K 3r   r   c                   t    e Zd Z ej                  dd      Z ej                  d      Z G d d      Zd Zy	)
IstatGender   Tr      r   c                       e Zd ZdZdgZy)IstatGender.Metaistat_genderr   Nr   r   r   r   r   r*      s    !8r   r   c                 8    | j                    d| j                   S r   )r   meaningr   s    r   r!   zIstatGender.__str__   s    ))C~..r   N)	r   r   r   r   r$   r   r-   r   r!   r   r   r   r&   r&      s7    6qd;Df"-G /r   r&   c                   N    e Zd Z ej                  dd      Z G d d      Zd Zy)IstatTourismTyper   Tr	   uniquec                       e Zd ZdZdgZy)IstatTourismType.Metaistat_tourism_typenameNr   r   r   r   r   r3       s    '8r   r   c                     | j                   S Nr5   r   s    r   r!   zIstatTourismType.__str__$       yyr   Nr   r   r   r   r$   r5   r   r!   r   r   r   r/   r/      %    6r$7D r   r/   c                   N    e Zd Z ej                  dd      Z G d d      Zd Zy)IstatTransportTyper   Tr0   c                       e Zd ZdZdgZy)IstatTransportType.Metaistat_transport_typer5   Nr   r   r   r   r   r?   +       )8r   r   c                     | j                   S r7   r8   r   s    r   r!   zIstatTransportType.__str__/   r9   r   Nr:   r   r   r   r=   r=   (   r;   r   r=   c                       e Zd Z ej                  dd      Z ej                  d      Z ej                  ddd      Z G d d	      Zd
 Z	y)IstatCountry	   Tr      r      r	   blanknullc                       e Zd ZdZdgZy)IstatCountry.Metaistat_countriesr5   Nr   r   r   r   r   rL   8       $8r   r   c                 :    | j                    d| j                   dS Nz ()r5   r   r   s    r   r!   zIstatCountry.__str__<       ))Btyyk++r   N)
r   r   r   r   r$   r   r5   iso_coder   r!   r   r   r   rD   rD   3   sM    6qd;D6s+Dv1DtDH ,r   rD   c                   *    e Zd Z ej                  dd      Z ej                  d      Z ej                  ddd      Z ej                  ddd      Z ej                  ddd      Z	 ej                  d	      Z G d
 d      Z fdZd Z xZS )IstatMunicipalityrE   Tr   rF   r   )r	   rI   db_indexr   rH   )defaultc                       e Zd ZdZdgZ ej                  dgd       ej                  ddgd       ej                  dgd	      gZy
)IstatMunicipality.Metaistat_municipalitiesr5   provinceistat_muni_province_idx)fieldsr5   normalized_nameistat_muni_prov_name_idx	is_activeistat_muni_active_idxN)r   r   r   r   r   r   Indexindexesr   r   r   r   rZ   H   sW    )8FLL3LMFLL"$56/ FLL4KL
r   r   c                     ddl m}  || j                        | _        | j                  r-| j                  j                         j                         | _        t        |    |i | y )Nr   )normalize_municipality_name)	istat.municipalitiesrf   r5   r_   r\   stripuppersupersave)r    argskwargsrf   	__class__s       r   rk   zIstatMunicipality.saveT   sL    D:499E== MM//1779DMd%f%r   c                 :    | j                    d| j                   dS rP   rR   r   s    r   r!   zIstatMunicipality.__str__\   rS   r   )r   r   r   r   r$   r   r5   r_   r\   regionBooleanFieldra   r   rk   r!   __classcell__)rn   s   @r   rV   rV   @   s    6qd;D6s+D&f&&#TDQOv1DtDHVDtDF###D1I

 

&,r   rV   c                       e Zd Z ej                  dd      Z ej                  d      Z ej                  ddd      Z G d d      Zd	 Z	y
)IstatProvincer   Tr   rF   r   rH   c                       e Zd ZdZdgZy)IstatProvince.Metaistat_provincesr5   Nr   r   r   r   r   rv   e   rN   r   r   c                 :    | j                    d| j                   dS rP   rR   r   s    r   r!   zIstatProvince.__str__i   rS   r   N)
r   r   r   r   r$   r   r5   rp   r   r!   r   r   r   rt   rt   `   sM    6qd;D6s+DVDtDF ,r   rt   c                   t    e Zd Z ej                  dd      Z ej                  d      Z G d d      Zd Zy	)
IstatDocumentType   Tr   rF   r   c                       e Zd ZdZdgZy)IstatDocumentType.Metaistat_document_typesr   Nr   r   r   r   r   r}   q   rA   r   r   c                 8    | j                    d| j                   S r   r   r   s    r   r!   zIstatDocumentType.__str__u   r"   r   Nr#   r   r   r   rz   rz   m   s7    6qd;D"&""c2K 3r   rz   c                       e Zd Z ej                  dej
                  d      Z ej                  dej
                  d      Z ej                  dd      Z	 ej                  d      Z G d	 d
      Zd Zy)IstatReservationPositionzbookings.Bookingistat_positions	on_deleterelated_namezguests.Guest
   Tr0   auto_now_addc                       e Zd ZdZddgZdgZy)IstatReservationPosition.Metaistat_reservation_positionsreservationguest
created_atN)r   r   r   r   unique_togetherr   r   r   r   r   r      s    0('2 >r   r   c                 R    | j                    d| j                   d| j                   S )N-z => )reservation_idguest_idistat_position_coder   s    r   r!   z IstatReservationPosition.__str__   s+    %%&ad4;S;S:TUUr   N)r   r   r   r   
ForeignKeyCASCADEr   r   r$   r   DateTimeFieldr   r   r!   r   r   r   r   r   y   s{    #&##..&K
 F..&E
 +&**bF%%%48J" "
Vr   r   c                      e Zd Z ej                  dej
                  d      Z ej                         Z ej                         Z	 ej                  eej                  ddd      Z ej                  eej                  ddd      Z ej                  d      Z ej                  d	      Z G d
 d      Zd Zed        Zej,                  d        Zed        Zej,                  d        Zed        Zy)IstatCredentialstructures.Structureistat_credentialr   Tcreated_istat_credentialsr   rJ   rI   r   updated_istat_credentialsr   )auto_nowc                       e Zd ZdZdgZy)IstatCredential.Metaistat_credentialsstructure_idNr   r   r   r   r   r      s    &"#r   r   c                      d| j                    S )NzISTAT credentials for )	structurer   s    r   r!   zIstatCredential.__str__   s    ''788r   c                 2    ddl m}  || j                        S Nr'   )decrypt_istat_secret)securityr   username_encryptedr    r   s     r   usernamezIstatCredential.username       2#D$;$;<<r   c                 *    ddl m}  ||      | _        y Nr'   )encrypt_istat_secret)r   r   r   r    valuer   s      r   r   zIstatCredential.username       2"6u"=r   c                 2    ddl m}  || j                        S r   )r   r   password_encryptedr   s     r   passwordzIstatCredential.password   r   r   c                 *    ddl m}  ||      | _        y r   )r   r   r   r   s      r   r   zIstatCredential.password   r   r   c                 2    ddl m}  || j                        S )Nr'   )mask_istat_secret)r   r   r   )r    r   s     r   masked_passwordzIstatCredential.masked_password   s    / !8!899r   N)r   r   r   r   OneToOneFieldr   r   	TextFieldr   r   r   r   SET_NULL
created_by
updated_byr   r   
updated_atr   r!   propertyr   setterr   r   r   r   r   r   r      s2   $$$..'I
 *))+)))+"""//0J #""//0J &%%48J%%%t4J$ $9 = =
 __> >
 = =
 __> >
 : :r   r   c                   R   e Zd Z G d dej                        Z ej                  dej                  d      Z ej                  dej                  ddd	      Z
 ej                  eej                  ddd	      Z ej                  d
ej                  ej                        Z ej                  dd      Z ej$                  ed      Z ej$                  ed      Z ej$                  ed      Z ej.                  d      Z ej.                  dd      Z G d d      Zd Zy)IstatSyncHistoryc                       e Zd ZdZdZdZy)IstatSyncHistory.Status)pendingPending)successSuccess)failedFailedN)r   r   r   PENDINGSUCCESSFAILEDr   r   r   Statusr      s    &&#r   r   r   istat_sync_historyr   r   Tsync_historyr   r(   )r	   choicesrX      )r	   rI   rX   rI   r   )rJ   rI   c                       e Zd ZdZdgZy)IstatSyncHistory.Metar   z-requested_atNr   r   r   r   r   r      s    '#$r   r   c                 T    | j                    d| j                   d| j                  dS Nz | z%Y-%m-%d %H:%M)r   statusrequested_atr   s    r   r!   zIstatSyncHistory.__str__   s+    ..!T[[MT5F5F~4VWWr   N)r   r   r   r   TextChoicesr   r   r   r   r   
credentialr   triggered_byr$   r   r   r   message	JSONFielddictrequested_periodrequest_payloadresponse_payloadr   r   completed_atr   r!   r   r   r   r   r      s2   $## $
 "!!..)I
 #""//#J %6$$//)L VF
 f#T:G'v''DA&f&&t4@O'v''DA'6''T:L'6''T>L% %Xr   r   c                      e Zd Z G d dej                        Z ej                  dej                  d      Z ej                  dej                  ddd	      Z
 ej                  d
ej                  ddd	      Z ej                  eej                  ddd	      Z ej                  dej                        Z ej                  d      Z ej$                  ed      Z ej*                  d      Z G d d      Zd Zy)IstatAuditLogc                       e Zd ZdZdZdZdZy)IstatAuditLog.Action)credential_createdzCredential Created)credential_updatedzCredential Updated)credential_deletedzCredential Deleted)sync_triggeredzSync TriggeredN)r   r   r   CREDENTIAL_CREATEDCREDENTIAL_UPDATEDCREDENTIAL_DELETEDSYNC_TRIGGEREDr   r   r   Actionr      s    GGG;r   r   r   istat_audit_logsr   r   T
audit_logsr   r       )r	   r   r   r   r   r   c                       e Zd ZdZdgZy)IstatAuditLog.Metar   z-created_atNr   r   r   r   r   r   "  s    %!?r   r   c                 T    | j                    d| j                   d| j                  dS r   )r   actionr   r   s    r   r!   zIstatAuditLog.__str__&  s)    ..!T[[MT__^4TUUr   N)r   r   r   r   r   r   r   r   r   r   r   sync_recordr   actorr$   r   r   r   r   r   metadatar   r   r   r!   r   r   r   r   r      s   <## < "!!..'I
 #""//!J $&##//!K F//'E VV^^DFf#.GvD9H%%%48J# #Vr   r   N)	django.dbr   django.contrib.auth.modelsr   Modelr   r&   r/   r=   rD   rV   rt   rz   r   r   r   r   r   r   r   <module>r      s     +	3V\\ 	3	/&,, 	/v||  
,6<< 
,, ,@
,FLL 
,	3 	3Vv|| V.<:fll <:~*Xv|| *XZ+VFLL +Vr   