
    vg^
                     J    d dl Z d dlmZ d dlmZmZ d dlmZ  G d de      Zy)    N)User)BaseCommandCommandError)Employeec                       e Zd ZdZd Zd Zy)CommandzCreates a new userc                 $   |j                  dt        d       |j                  dt        d       |j                  dt        d       |j                  dt        d	       |j                  d
t        d       |j                  dt        d       y )Nz--first_namezFirst name of the new user)typehelpz--last_namezLast name of the new userz
--usernamezUsername of the new userz
--passwordzPassword for the new userz--emailzEmail of the new userz--phonezPhone number of the new user)add_argumentstr)selfparsers     >/var/www/horilla/base/management/commands/createhorillauser.pyadd_argumentszCommand.add_arguments   s    N;WXM:UVLs9STLs9TUIC6MNIC6TU    c                 
   |d   sCt        d      }t        d      }t        d      }t        d      }t        d      }t        d      }n|d   }|d   }|d	   }|d
   }|d   }|d   }t        j                  j                  |      j	                         }	|	8| j
                  j                  | j                  j                  d|	z               y 	 t        j                  j                  |||      }
t               }|
|_        ||_        ||_        ||_        ||_        |j!                          t        j                  j                  d      j	                         }|<t        j                  j#                  dt%        t'        j(                                      | j
                  j                  | j                  j+                  d|z               y # t,        $ r&}
j/                          t1        d|d|      d }~ww xY w)N
first_namezEnter first name: zEnter last name: zEnter username: zEnter password: zEnter email: zEnter phone number: 	last_nameusernamepasswordemailphone)r   zUser "%s" already exist)r   r   r   zHorilla Bot)r   r   z"Employee "%s" created successfullyzError creating user "z": )inputr   objectsfilterfirststdoutwritestyleWARNINGcreate_superuserr   employee_user_idemployee_first_nameemployee_last_namer   r   savecreate_userr   uuiduuid4SUCCESS	Exceptiondeleter   )r   argsoptionsr   r   r   r   r   r   	adminuseruseremployeebotes                 r   handlezCommand.handle   s   |$34J12I/0H/0H/*E01E .J,Iz*Hz*HG$EG$ELL'''<BBD	 KKdjj001JY1VWXS||44%UX 5  $:,0)/9,.7+!&!&ll))=)AGGI;LL,,!.!$TZZ\!2 - 
 !!JJ&&'Kh'VW  S"Xq#QRRSs   DG 	H!G==HN)__name__
__module____qualname__r   r   r4    r   r   r   r   	   s    DV+Sr   r   )	r(   django.contrib.auth.modelsr   django.core.management.baser   r   employee.modelsr   r   r8   r   r   <module>r<      s     + A $6Sk 6Sr   