-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dev): registration simplification (#291)
- Loading branch information
Showing
26 changed files
with
335 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,58 @@ | ||
from allauth.account import signals | ||
from allauth.account.adapter import DefaultAccountAdapter | ||
from allauth.account.utils import user_field | ||
from django.contrib import messages | ||
from django.http import HttpResponseRedirect | ||
|
||
|
||
class AccountAdapter(DefaultAccountAdapter): | ||
def post_login( | ||
self, | ||
request, | ||
user, | ||
*, | ||
email_verification, | ||
signal_kwargs, | ||
email, | ||
signup, | ||
redirect_url | ||
): | ||
from allauth.account.utils import get_login_redirect_url | ||
|
||
response = HttpResponseRedirect( | ||
get_login_redirect_url(request, redirect_url, signup=signup) | ||
) | ||
|
||
if signal_kwargs is None: | ||
signal_kwargs = {} | ||
signals.user_logged_in.send( | ||
sender=user.__class__, | ||
request=request, | ||
response=response, | ||
user=user, | ||
**signal_kwargs, | ||
) | ||
|
||
if user.registered: | ||
self.add_message( | ||
request, | ||
messages.SUCCESS, | ||
"account/messages/logged_in.txt", | ||
{"user": user}, | ||
) | ||
|
||
return response | ||
|
||
def save_user(self, request, user, form, commit=False): | ||
""" | ||
Saves a new `User` instance using information provided in the | ||
signup form. | ||
""" | ||
user = super().save_user(request, user, form, commit) | ||
data = form.cleaned_data | ||
user_field(user, "middle_name", data.get("middle_name", "")) | ||
user_field(user, "company", data.get("company"), "") | ||
user_field(user, "position", data.get("position"), "") | ||
user_field(user, "phone", data.get("phone"), "") | ||
setattr(user, "region_id", getattr(data.get("region"), "code", None)) | ||
setattr(user, "city_id", getattr(data.get("city"), "id", None)) | ||
if user.last_name is not None and len(user.last_name): | ||
user.note = user.last_name | ||
user.last_name = None | ||
user.save() | ||
return user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{% extends "account/base_col6.html" %} | ||
|
||
{% load static %} | ||
|
||
{% block title %}Завершение регистрации. {% endblock %} | ||
|
||
{% block description %}Завершение регистрации на аналитическом сервисе для развития туризма ацеста{% endblock %} | ||
|
||
{% block ogtitle %}Завершение регистрации. {% endblock %} | ||
|
||
{% block ogimage %}{% static 'img/og/login.png' %}{% endblock %} | ||
{% block ogimage_secure %}{% static 'img/og/login.png' %}{% endblock %} | ||
|
||
{% block vkimage %}{% static 'img/og/login.vk.png' %}{% endblock %} | ||
{% block vkimage_secure %}{% static 'img/og/login.vk.png' %}{% endblock %} | ||
|
||
{% block css_external %} | ||
<link rel="stylesheet" href="{% static 'css/select2.min.css' %}"> | ||
{{ block.super }} | ||
{% endblock %} | ||
|
||
{% block content_block %} | ||
<h1>Завершение регистрации</h1> | ||
<form class="signup" id="signup_form" method="post" action="{% url 'account_signupnext' %}"> | ||
{% csrf_token %} | ||
{% include "include/sign_up_fields_2.html" %} | ||
</form> | ||
{% endblock %} | ||
|
||
{% block js %} | ||
{{ block.super }} | ||
<script src="{% static 'js/region.selector.js' %}"></script> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.