
    ee`                     ^    d dl mZ d dlZd dlZd dlZd dlZd dlmZ d Zd Z	d
dZ
d Zd	 ZdS )    )FileSystemStorageN)settingsc                  D   dd l dd ld                    fdt          d          D                       } | d                    fdt          d          D                       z  } t	          |           } j        |           d                    |          }|S )Nr    c              3   B   K   | ]} j         j                  V  d S N)choiceascii_letters.0xrandomstrings     @/var/www/html/Investors/ModernInvestors/admin_panel/functions.py	<genexpr>z/randomStringFunctionForImage.<locals>.<genexpr>	   s2      JJAMFM&"677JJJJJJ       c              3   B   K   | ]} j         j                  V  d S r   )r	   digitsr   s     r   r   z/randomStringFunctionForImage.<locals>.<genexpr>
   s1      DDa]V]6=11DDDDDDr      )r   r   joinrangelistshuffle)str1sam_listfinalStringr   r   s      @@r   randomStringFunctionForImager      s    77JJJJJqJJJKKDBGGDDDDD588DDDEEEDDzzHFN8''(##Kr   c                 .   d}t          |          }d}t          j                            | j                  d         }t                      }t          |          t          |          z   }|                    ||           }t          |          dz   |z   S )Nzmedia/admin)location   /)r   ospathsplitextnamer   strsave)imagefullPathfs	fullPath2filetypetheNametheImageNamefilenames           r   uploadTheImagesr1      s    H	H	-	-	-BIw
++A.H(**GWc(mm+Lww|U++Hy>>#h&&r      c                     t           j        t           j        z   t           j        z   }d                    t          j        ||                     }|S )Nr   )r   r
   r   punctuationr   r   sample)length
characterspasswords      r   generate_random_passwordr9      s;    %58JJJwwv}Z8899HOr   c                      	 t           j        t          _        t          j                            d          } | r	| d         }nd}n&# t          $ r}t          |           Y d }~nd }~ww xY w|S )NzCustomer stripe card)descriptionidr   )r   STRIPE_SECRET_KEYstripeapi_keyCustomercreate	Exceptionprint)customerstrip_ides      r   generate_strip_idrG   "   s    
-&._##% $  (  tn888   ((((((((s   AA 
A)A$$A)c                    i }	 t          |          }t          |          }t          |          }t          d           |}t          d           t          |          }t          j        t          _        t          j        	                    d| ||dz  d          }|r
d|d<   ||d	<   n.# t          $ r!}d
|d<   t          |          |d<   Y d }~nd }~ww xY w|S )Nworking1working2USDd   zcharge from user)currencyrD   cardamountr;   TstatusdataFmessage)r'   floatintrC   r   r=   r>   r?   ChargerA   rB   )customerStripeIdcardIdtotalAmountresponsestripeAmountChargesrF   s         r   paymentWithExistingCardr[   3   s   K  +k""+K  +
+
K  ++&.,,
c/# -    *8H)8F 	   (8A(9 	s   B%B* *
C4CC)r2   )django.core.files.storager   r#   r   r   r>   django.confr   r   r1   r9   rG   r[    r   r   <module>r_      s    7 7 7 7 7 7 				                       ' ' '     "    r   