
    Z-h                         d dl mZ d dlmZ d dlmZ d dlZd dlmZ d dl	m
Z
mZmZmZmZmZ d dlmZ d dlmZ d dlZd dlZd dlZ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#y)    )models)
ColorField)format_htmlN)StyledPilImage)SquareModuleDrawerGappedSquareModuleDrawerCircleModuleDrawerRoundedModuleDrawerVerticalBarsDrawerHorizontalBarsDrawer)SolidFillColorMask)BytesIO)RichTextField)gettext_lazyc                       e Zd Z ej                         Z ej                  d      Z ej                  dd      Z	 ej                  d      Z ej                  dd      Z ej                  dd      Zd Zy	)
FeedbackT)blankd   )
max_lengthr   auto_now_add   r   nullc                 @    | j                    d| j                  xs d S )Nz	 stars - 	Anonymous)ratingcontactselfs    +/var/www/skyplay_api_hub/feedback/models.py__str__zFeedback.__str__   s!    ++i(C'DEE    N)__name__
__module____qualname__r   PositiveSmallIntegerFieldr   	TextFieldcomment	CharFieldr   DateTimeFieldsubmitted_atreferrerGenericIPAddressField
ip_addressr"    r#   r!   r   r      sx    -V--/FfT*Gf#T:G'6''T:Lv3d;H---DtDJFr#   r   c                   6   e Zd Zg dZg dZ G d d      Z ej                  d      Z ej                         Z
 ej                  dd	      Z ed
d	      Z edd	      Z ej                  ded      Z ej                  ded      Zd Zd Zde_        y)QRcodeGenerate)squareSquare)gapped_squarezGapped SquarecircleCircleroundedRounded)vertical_barszVertical Bars)horizontal_barszHorizontal Bars)r3   r7   r:   c                       e Zd ZdZdZy)QRcodeGenerate.MetazQR Code GenerateNr$   r%   r&   verbose_nameverbose_name_pluralr0   r#   r!   Metar@   2   s    )0r#   rD   r   r   
   zSize of each box in the QR code)default	help_textz#000000zColor of the QR codez#FFFFFFzBackground color of the QR code   r4   )r   choicesrG   c                 N    j                  d      t        fddD              S )z&Convert hex color string to RGB tuple.#c              3   B   K   | ]  }t        ||d z    d        yw)      N)int).0i	hex_colors     r!   	<genexpr>z,QRcodeGenerate.hex_to_rgb.<locals>.<genexpr>A   s#     B1S1QqS)2.Bs   )r   rN      )lstriptuple)r    rS   s    `r!   
hex_to_rgbzQRcodeGenerate.hex_to_rgb>   s$    $$S)	B	BBBr#   c           	      r   t               t               t               t               t	               t               d}t               t               t               d}t        j                  dt        j                  j                  | j                  d      }|j                  | j                         |j                  d       | j                  | j                        }| j                  | j                         }|j#                  t$        |j'                  | j(                  t                     |j'                  | j*                  t                     t-        ||      	      }t/               }|j1                  |d
       t3        j4                  |j7                               j9                         }t;        d||      S )N)r4   r6   r8   r;   r=   r>   )r4   r8   r;      rU   )versionerror_correctionbox_sizeborderT)fit)
back_colorfront_color)image_factorymodule_drawer
eye_drawer
color_maskPNG)formata  
            <img src="data:image/png;base64,{}" width="150" height="150" id="qr-image"/>
            <br/>
            <a href="data:image/png;base64,{}" download="qr_code.png">
                <button type="button">Download QR Code</button>
            </a>
            <button type="button" onclick="printQRCode()">Print QR Code</button>
            <script>
                function printQRCode() {{
                    var img = document.getElementById('qr-image');
                    var w = window.open();
                    w.document.write('<img src="' + img.src + '" onload="window.print();window.close()" />');
                    w.document.close();
                }}
            </script>
            )r   r   r	   r
   r   r   qrcodeQRCode	constantsERROR_CORRECT_Hqr_sizeadd_dataurlmakerX   qr_colorqr_background
make_imager   getrc   rd   r   r   savebase64	b64encodegetvaluedecoder   )	r    module_drawer_mappingeye_drawer_mappingqrra   r`   imgbufferimg_strs	            r!   qr_codezQRcodeGenerate.qr_codeC   se    )*57(**,/135!
 )*(**,
 ]]#--==\\	
 	DHH
D oodmm4__T%7%78
mm(/33D4F4FHZH\])--doo?Q?ST)Z[Y	  
 &""6??#45<<>  %
 	
r#   zQR CodeN)r$   r%   r&   MODULE_DRAWER_CHOICESEYE_DRAWER_CHOICESrD   r   r*   nameURLFieldrn   PositiveIntegerFieldrl   r   rp   rq   rc   rd   rX   r   short_descriptionr0   r#   r!   r2   r2   "   s    1 1 6s+D
&//
C)f))"@abG)7MNHy<]^M$F$$<Q[cdM!!!R9KU]^JC
<
| !*Gr#   r2   c                       e Zd Z ej                  d      Z ej                  dd      Z ej                  d      Z ej                  dd      Z
 ej                  d	      Zd
 Zd Zd Zy)FaceProfiler   rE   rI   Tr   uniquezfaces/)	upload_tor   r   c                 T    t        j                  |j                               | _        y N)jsondumpstolistface_encoding)r    encoding_arrays     r!   set_encodingzFaceProfile.set_encoding   s    !ZZ(=(=(?@r#   c                     | j                   r2t        j                  t        j                  | j                               S y r   )r   nparrayr   loadsr   s    r!   get_encodingzFaceProfile.get_encoding   s,    88DJJt'9'9:;;r#   c                     | j                   S r   )r   r   s    r!   r"   zFaceProfile.__str__   s    yyr#   N)r$   r%   r&   r   r*   r   phone_number
ImageField
face_imager(   r   r+   
created_atr   r   r"   r0   r#   r!   r   r      sp    6s+D#6##r$?L"""X6J$F$$4d;M%%%48JA
r#   r   c                   l   e Zd Z ej                  ddddd ed            Z ej                  ddd ed            Z ej                  dej                  d	ddd ed
            Z ej                  ddd ed            Z ej                  ddddd ed            Zd Zd Zd Z G d d      Zy)ChatCategoryr   TNzCategory Name)r   r   r   r   rG   rB   Description)r   r   rG   rB   r    subcategorieszParent Category)	on_deleterelated_namer   r   rG   rB   z	Is Active)rG   r   r   rB   2   zCategory Codec                 N    | j                   rdnd}| j                  xs d d| dS )NActiveInactivezUnnamed Categoryz ())	is_activer   )r    statuss     r!   r"   zChatCategory.__str__   s-    !^^))112"VHA>>r#   c                 6    | j                   j                         S r   )r   allr   s    r!   get_childrenzChatCategory.get_children   s    !!%%''r#   c                     | j                   d u S r   )parentr   s    r!   is_rootzChatCategory.is_root   s    {{d""r#   c                   ,    e Zd Z ed      Z ed      Zy)ChatCategory.MetazChat CategoryzChat CategoriesN)r$   r%   r&   _rB   rC   r0   r#   r!   rD   r      s    ) 12r#   rD   )r$   r%   r&   r   r*   r   r   r(   description
ForeignKeyCASCADEr   BooleanFieldr   coder"   r   r   rD   r0   r#   r!   r   r      s    6'D #&""}%	K V..$()F $##{^	I 6'D?(#3 3r#   r   c                       e Zd Z ej                  dd      Z e       Z ej                  dej                  dddd      Z
 ej                  d      Zd	 Z G d
 d      Zy)PredefinedQAr   Tr   r   predefined_qaCategory)r   r   r   r   rB   rG   c                     | j                   S r   )questionr   s    r!   r"   zPredefinedQA.__str__   s    }}r#   c                       e Zd ZdZdZy)PredefinedQA.MetazChat Botz	Chat BotsNrA   r0   r#   r!   rD   r      s    !)r#   rD   N)r$   r%   r&   r   r*   r   r   answerr   SET_NULLcategoryr   activer"   rD   r0   r#   r!   r   r      sh    v3t<H_F v  //$H !V  .F* *r#   r   c                      e Zd Z ej                  d      Z ej                  dd      Z ej                  ddd      Z ej                  dd      Z	 ej                  d	
      Z ej                  d      Zd Zd Zy)ChatLogr   rE   Tr   rI   )r   r   r   r   r   z[]r   )auto_nowc                 d    	 t        j                  | j                        S # t        $ r g cY S w xY wr   )r   r   conversation	Exceptionr   s    r!   get_conversationzChatLog.get_conversation   s0    	::d//00 	I	s   ! //c                 :    d| j                    d| j                   S )Nz
Chat from z at )	user_name	timestampr   s    r!   r"   zChatLog.__str__   s    DNN+4/?@@r#   N)r$   r%   r&   r   r*   r   
EmailField
user_email
user_phone
session_idr(   r   r+   r   r   r"   r0   r#   r!   r   r      s       C0I"""D9J!!!Rt$GJ!!!R=J#6##D1L$$$d3IAr#   r   )$	django.dbr   colorfield.fieldsr   django.utils.htmlr   rh   qrcode.image.styledpilr   !qrcode.image.styles.moduledrawersr   r   r	   r
   r   r   qrcode.image.styles.colormasksr   ior   ru   r   numpyr   ckeditor.fieldsr   django.utils.translationr   r   Modelr   r2   r   r   r   r   r0   r#   r!   <module>r      s     ( )  1  >     ) 6	Fv|| 	F_*V\\ _*D&,, &336<< 33j*6<< *0Afll Ar#   