-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Создание простой формы регистрации #40
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
fded092
Добавлена форма регистрации
bbfc653
Реализована простая форма регистрации пользователя и исправлен Makefi…
779a556
Добавил временный генератор telegram_id и исправил в модели Integer н…
d946949
Merge branch 'dev' into feature/registration_form
DBratkov 8a1914a
Change for ruff
e4f4359
Исправил по PEP forms.py
3468ec3
add django-bootstrap5 in poetry
KonstantinRaikhert f150f7c
resolve conflicts
KonstantinRaikhert 9279b1e
Исправлены недочеты по ревью
10b0637
new migrations in potential_user
KonstantinRaikhert File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Empty file.
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 |
---|---|---|
@@ -1,10 +1,15 @@ | ||
from django.contrib import admin | ||
from django.urls import path | ||
from django.urls import path, include | ||
|
||
|
||
from core.views import send_greeting_email | ||
|
||
urlpatterns = [ | ||
path('admin/', admin.site.urls), | ||
path('registration/', | ||
include('potential_user.urls'), | ||
name='registration', | ||
), | ||
# TODO: убрать после реализации функционала | ||
path('mail/', send_greeting_email, name='send-email'), | ||
] |
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,13 @@ | ||
from django import forms | ||
|
||
from potential_user.models import ApplicationForm | ||
|
||
|
||
class RegistrationForm(forms.ModelForm): | ||
"""Form to register a new user.""" | ||
|
||
class Meta: | ||
"""Form meta class.""" | ||
|
||
model = ApplicationForm | ||
fields = {'name', 'surname', 'phone_number', 'city', } |
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,11 @@ | ||
from django.urls import path | ||
|
||
from potential_user.views import RegistrationCreateView | ||
|
||
app_name = 'registration' | ||
|
||
urlpatterns = [ | ||
path('', | ||
RegistrationCreateView.as_view(), | ||
name='registration'), | ||
] |
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,20 @@ | ||
import random | ||
import sys | ||
|
||
from potential_user.models import ApplicationForm | ||
|
||
#TODO Убрать после реализации хендлеров | ||
def get_telegram_id() -> int: | ||
""" | ||
Получает телеграм id от бота. | ||
|
||
Сейчас исполняет роль заглушки. | ||
""" | ||
while True: | ||
telegram_id = random.randint(0, sys.maxsize) | ||
tg_id_in_db = ApplicationForm.objects.filter( | ||
telegram_id=telegram_id, | ||
).exists() | ||
if tg_id_in_db: | ||
continue | ||
return telegram_id |
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,24 @@ | ||
from django.urls import reverse_lazy | ||
from django.views.generic import CreateView | ||
|
||
from potential_user.forms import RegistrationForm | ||
from potential_user.models import ApplicationForm | ||
from potential_user.utils import get_telegram_id | ||
|
||
|
||
class RegistrationCreateView(CreateView): | ||
"""Создает форму регистрации нового пользователя.""" | ||
|
||
model = ApplicationForm | ||
form_class = RegistrationForm | ||
template_name = 'registration/registration_form.html' | ||
|
||
# TODO убрать после реализации получения telegram_id | ||
def form_valid(self, form): | ||
"""Присваивает telegram_id.""" | ||
form.instance.telegram_id = get_telegram_id() | ||
return super().form_valid(form) | ||
|
||
def get_success_url(self): | ||
"""Переадресовывет на главную страницу.""" | ||
return reverse_lazy('registration:registration') |
Empty file.
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,15 @@ | ||
<!DOCTYPE html> | ||
<html lang="ru"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Телеграм-бот для преподавателей и учеников</title> | ||
{% load django_bootstrap5 %} | ||
{% bootstrap_css %} | ||
</head> | ||
<body> | ||
{% include "registration/header.html" %} | ||
<div class="container pt-5" align="center"> | ||
{% block content %}{% endblock %} | ||
</div> | ||
</body> | ||
</html> |
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,4 @@ | ||
{% load static %} | ||
<footer class="footer"> | ||
|
||
</footer> |
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,4 @@ | ||
{% load static %} | ||
<header class="header-login"> | ||
<h1 align="center">Телеграм-бот <br/> для преподавателей и учеников</h1> | ||
</header> |
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,16 @@ | ||
{% extends "registration/base.html" %} | ||
{% load django_bootstrap5 %} | ||
{% block content %} | ||
<div class="card col-4"> | ||
<div class="card-header"> | ||
Регистрация пользователя | ||
</div> | ||
<div class="card-body"> | ||
<form method="post" enctype="multipart/form-data"> | ||
{% csrf_token %} | ||
{% bootstrap_form form %} | ||
{% bootstrap_button button_type="submit" content="Регистрация" %} | ||
</form> | ||
</div> | ||
</div> | ||
{% endblock %} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Напиши еще #TODO Убрать после реализации хендлеров