U
    d                     @   sN   d dl mZ d dlZd dlmZ d dlT d dlmZ G dd dej	j
eZdS )    )abortN)commit_all_ds)*)ResponseMixinc                   @   sL   e Zd ZdZdej dZdej dZe	j
jdd Ze	j
jdd	 Zd
S )
SignupViewz/auth/signupu,   Обратитесь в <a href="https://wwwu9   /support/">техническую поддержку</a>.u   Перейти в <a href="u   ">Ваш профиль</a>?c                 C   s
   |  dS )Nzsignup.html)Zrender)self r   %./modules/servicedesk/views/signup.pyget   s    zSignupView.getc           	      C   s   ddl m} |tjd }tjd }tjd }tjd }tjd}tjd}tj|||}|sttd	 t	d
 ||_
|  ztjj||||d W n   td	  Y nX |j  dS )Nr   )normalize_email_addressloginhashsaltnamephonecompanyznot authi  )r   r   Zcompany_nameZphone_numberzSigned up successfully)Zmodules.auth.models.emailr   Zrequestvaluesr
   ZmodelsZCmfAuthZnew_from_login_hash_saltr   r   r   ZsaveZ	CmfPersonZcreate_sdesk_userZdpZcommit)	r   r   r   _hashr   r   r   r   Zauthr   r   r	   post   s(    



zSignupView.postN)__name__
__module____qualname__Z__url__ZconfigZAUTH_SESSION_COOKIE_DOMAINZ__support__ZAUTH_SERVER_URLZ__profile__cmfviewsactionr
   r   r   r   r   r	   r      s   
r   )Zflaskr   Z	cmf.viewsr   Zcmf.data_providers.baser   Zcmf.includeZmodules.auth.views.responser   r   ZBaseViewr   r   r   r   r	   <module>   s
   