o
    Lf                     @   sl  d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	m
Z
 d dlmZ d dlmZ d dlmZ d d	lmZ d
dlmZ d
dlmZ d
dlmZmZmZ d
dlmZ ddlmZm Z  ddl!mZ ddl"m#Z#m$Z$ ddl%m&Z&m'Z' G dd deeeeZ(e() Z*G dd deZ+e+) Z,G dd deZ-e-) Z.eeddd dddG dd  d eeZ/ee/) Z0d!S )"    )messages)login_required)get_current_site)HttpResponseRedirect)reversereverse_lazy)method_decorator)TemplateView)FormView)reauthentication_required   )app_settings)get_adapter)AjaxCapableProcessFormViewMixinCloseableSignupMixinRedirectAuthenticatedUserMixin)get_form_class   )r   helpers)DisconnectForm
SignupForm)SocialAccountSocialLoginc                       sb   e Zd ZeZdej Zdd Z fddZ	dd Z
 fdd	Zd
d Z fddZdd Z  ZS )
SignupViewzsocialaccount/signup.c                 C      t tjd| jS )Nsignupr   r   FORMS
form_classself r!   \/var/www/html/humari/django-venv/lib/python3.10/site-packages/allauth/socialaccount/views.pyr   #      zSignupView.get_form_classc                    sR   d | _ |jd}|rt|| _ | j sttdS tt| j	|g|R i |S )Nsocialaccount_socialloginaccount_login)
socialloginsessiongetr   deserializer   r   superr   dispatch)r    requestargskwargsdata	__class__r!   r"   r+   &   s   zSignupView.dispatchc                 C   s   t | j| j| jS N)r   r,   is_open_for_signupr&   r   r!   r!   r"   is_open/   s   
zSignupView.is_openc                       t t|  }| j|d< |S )Nr&   )r*   r   get_form_kwargsr&   )r    retr0   r!   r"   r6   4      
zSignupView.get_form_kwargsc                 C   s8   | j jdd  || j \}}|st| j | j}|S )Nr$   )r,   r'   poptry_saver   complete_social_signupr&   )r    formuserrespr!   r!   r"   
form_valid9   s
   zSignupView.form_validc                    s6   t t| jdi |}|tt| j| jjd |S )N)siteaccountr!   )	r*   r   get_context_dataupdatedictr   r,   r&   rA   )r    r.   r7   r0   r!   r"   rB   @   s   zSignupView.get_context_datac                 C   s   t tS r2   )r   connectionsr   r!   r!   r"   get_authenticated_redirect_urlJ   s   z)SignupView.get_authenticated_redirect_url)__name__
__module____qualname__r   r   account_settingsTEMPLATE_EXTENSIONtemplate_namer   r+   r4   r6   r?   rB   rF   __classcell__r!   r!   r0   r"   r      s    
	
r   c                   @      e Zd Zdej ZdS )LoginCancelledViewzsocialaccount/login_cancelled.NrG   rH   rI   rJ   rK   rL   r!   r!   r!   r"   rO   Q       rO   c                   @   rN   )LoginErrorViewz#socialaccount/authentication_error.NrP   r!   r!   r!   r"   rR   Z   rQ   rR   Tc                 C   s   t jS r2   )rJ   REAUTHENTICATION_REQUIRED)r,   r!   r!   r"   <lambda>f   s    rT   )	allow_getenabledr+   )namec                       sN   e Zd Zdej ZeZedZ	dd Z
 fddZ fddZd	d
 Z  ZS )ConnectionsViewzsocialaccount/connections.socialaccount_connectionsc                 C   r   )N
disconnectr   r   r!   r!   r"   r   o   r#   zConnectionsView.get_form_classc                    r5   )Nr,   )r*   rX   r6   r,   )r    r.   r0   r!   r"   r6   r   r8   zConnectionsView.get_form_kwargsc                    s,   t  | jtjd |  tt| |S )Nz/socialaccount/messages/account_disconnected.txt)	get_account_adapteradd_messager,   r   INFOsaver*   rX   r?   )r    r<   r0   r!   r"   r?   w   s   zConnectionsView.form_validc                 C   sF   g }t jj| jjdD ]}| }||j|j|	 d qd|iS )N)r=   )idproviderrW   socialaccounts)
r   objectsfilterr,   r=   get_provider_accountappendpkr`   to_str)r    account_datarA   provider_accountr!   r!   r"   get_ajax_data   s   zConnectionsView.get_ajax_data)rG   rH   rI   rJ   rK   rL   r   r   r   success_urlr   r6   r?   rj   rM   r!   r!   r0   r"   rX   c   s    
	rX   N)1django.contribr   django.contrib.auth.decoratorsr   django.contrib.sites.shortcutsr   django.httpr   django.urlsr   r   django.utils.decoratorsr   django.views.generic.baser	   django.views.generic.editr
   allauth.account.decoratorsr   rA   r   rJ   account.adapterr   r[   account.viewsr   r   r   utilsr    r   adapterformsr   r   modelsr   r   r   as_viewr   rO   login_cancelledrR   login_errorrX   rE   r!   r!   r!   r"   <module>   sJ    
4$