From fded0925c005cb07406f06ae335e18004b772418 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C2=AB=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9?=
<«dmitriy@bratkov.su»>
Date: Sat, 11 May 2024 19:51:16 +0300
Subject: [PATCH 1/8] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?=
=?UTF-8?q?=D0=BD=D0=B0=20=D1=84=D0=BE=D1=80=D0=BC=D0=B0=20=D1=80=D0=B5?=
=?UTF-8?q?=D0=B3=D0=B8=D1=81=D1=82=D1=80=D0=B0=D1=86=D0=B8=D0=B8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/admin_user/migrations/__init__.py | 0
src/bot/migrations/__init__.py | 0
src/core/config/settings_base.py | 5 ++++-
src/core/urls.py | 7 ++++++-
src/potential_user/forms.py | 12 ++++++++++++
src/potential_user/migrations/__init__.py | 0
src/potential_user/models.py | 12 ++++++------
src/potential_user/urls.py | 11 +++++++++++
src/potential_user/views.py | 11 +++++++++++
src/schooling/migrations/__init__.py | 0
src/templates/registration/base.html | 15 +++++++++++++++
src/templates/registration/footer.html | 4 ++++
src/templates/registration/header.html | 4 ++++
.../registration/registration_form.html | 16 ++++++++++++++++
14 files changed, 89 insertions(+), 8 deletions(-)
delete mode 100644 src/admin_user/migrations/__init__.py
delete mode 100644 src/bot/migrations/__init__.py
create mode 100644 src/potential_user/forms.py
delete mode 100644 src/potential_user/migrations/__init__.py
create mode 100644 src/potential_user/urls.py
create mode 100644 src/potential_user/views.py
delete mode 100644 src/schooling/migrations/__init__.py
create mode 100644 src/templates/registration/base.html
create mode 100644 src/templates/registration/footer.html
create mode 100644 src/templates/registration/header.html
create mode 100644 src/templates/registration/registration_form.html
diff --git a/src/admin_user/migrations/__init__.py b/src/admin_user/migrations/__init__.py
deleted file mode 100644
index e69de29..0000000
diff --git a/src/bot/migrations/__init__.py b/src/bot/migrations/__init__.py
deleted file mode 100644
index e69de29..0000000
diff --git a/src/core/config/settings_base.py b/src/core/config/settings_base.py
index ae7fc8a..6fc59ce 100644
--- a/src/core/config/settings_base.py
+++ b/src/core/config/settings_base.py
@@ -28,6 +28,7 @@
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
+ 'django_bootstrap5',
]
LOCAL_APPS = [
@@ -53,10 +54,12 @@
ROOT_URLCONF = 'core.urls'
+TEMPLATES_DIR = BASE_DIR / 'templates'
+
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
- 'DIRS': [],
+ 'DIRS': [TEMPLATES_DIR],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
diff --git a/src/core/urls.py b/src/core/urls.py
index dfc7362..35080fc 100644
--- a/src/core/urls.py
+++ b/src/core/urls.py
@@ -1,6 +1,11 @@
from django.contrib import admin
-from django.urls import path
+from django.urls import path, include
+
urlpatterns = [
path('admin/', admin.site.urls),
+ path('registration/',
+ include('potential_user.urls'),
+ name='registration',
+ ),
]
diff --git a/src/potential_user/forms.py b/src/potential_user/forms.py
new file mode 100644
index 0000000..0bfbaa0
--- /dev/null
+++ b/src/potential_user/forms.py
@@ -0,0 +1,12 @@
+from django import forms
+from phonenumber_field.formfields import PhoneNumberField
+
+from .models import ApplicationForm
+
+
+class RegistrationForm(forms.ModelForm):
+
+ class Meta:
+ model = ApplicationForm
+ fields = {'telegram_id', 'name', 'surname', 'phone_number', 'city', }
+
diff --git a/src/potential_user/migrations/__init__.py b/src/potential_user/migrations/__init__.py
deleted file mode 100644
index e69de29..0000000
diff --git a/src/potential_user/models.py b/src/potential_user/models.py
index 3348b7d..b0a27f6 100644
--- a/src/potential_user/models.py
+++ b/src/potential_user/models.py
@@ -10,12 +10,12 @@ class ApplicationForm(models.Model):
('student', 'Учащийся'),
)
- telegram_id = models.IntegerField('Telegram ID', unique=True)
- role = models.CharField(choices=ROLE_CHOICES, max_length=20)
- name = models.CharField(max_length=20)
- surname = models.CharField(max_length=20)
- city = models.CharField(max_length=20)
- phone_number = PhoneNumberField()
+ telegram_id = models.IntegerField('Telegram ID', unique=True, help_text='Введите свой ID')
+ role = models.CharField('Роль', choices=ROLE_CHOICES, max_length=20)
+ name = models.CharField('Имя', max_length=20, help_text="Обязательное поле")
+ surname = models.CharField('Фамилия', max_length=20, help_text="Обязательное поле")
+ city = models.CharField('Город', max_length=20)
+ phone_number = PhoneNumberField('Номер телефона')
approved = models.BooleanField(default=False)
class Meta:
diff --git a/src/potential_user/urls.py b/src/potential_user/urls.py
new file mode 100644
index 0000000..e7691eb
--- /dev/null
+++ b/src/potential_user/urls.py
@@ -0,0 +1,11 @@
+from django.urls import path
+
+from .views import RegistrationCreateView
+
+app_name = 'registration'
+
+urlpatterns = [
+ path('',
+ RegistrationCreateView.as_view(),
+ name='registration'),
+]
diff --git a/src/potential_user/views.py b/src/potential_user/views.py
new file mode 100644
index 0000000..bc05a6a
--- /dev/null
+++ b/src/potential_user/views.py
@@ -0,0 +1,11 @@
+from django.views.generic import CreateView
+
+from .models import ApplicationForm
+from .forms import RegistrationForm
+
+
+class RegistrationCreateView(CreateView):
+
+ model = ApplicationForm
+ form_class = RegistrationForm
+ template_name = 'registration/registration_form.html'
diff --git a/src/schooling/migrations/__init__.py b/src/schooling/migrations/__init__.py
deleted file mode 100644
index e69de29..0000000
diff --git a/src/templates/registration/base.html b/src/templates/registration/base.html
new file mode 100644
index 0000000..bda4354
--- /dev/null
+++ b/src/templates/registration/base.html
@@ -0,0 +1,15 @@
+
+
+
+
+ Телеграм-бот для преподавателей и учеников
+ {% load django_bootstrap5 %}
+ {% bootstrap_css %}
+
+
+ {% include "registration/header.html" %}
+
+ {% block content %}{% endblock %}
+
+
+
\ No newline at end of file
diff --git a/src/templates/registration/footer.html b/src/templates/registration/footer.html
new file mode 100644
index 0000000..be2b40f
--- /dev/null
+++ b/src/templates/registration/footer.html
@@ -0,0 +1,4 @@
+{% load static %}
+
diff --git a/src/templates/registration/header.html b/src/templates/registration/header.html
new file mode 100644
index 0000000..b5f60cc
--- /dev/null
+++ b/src/templates/registration/header.html
@@ -0,0 +1,4 @@
+{% load static %}
+
\ No newline at end of file
diff --git a/src/templates/registration/registration_form.html b/src/templates/registration/registration_form.html
new file mode 100644
index 0000000..ebe9823
--- /dev/null
+++ b/src/templates/registration/registration_form.html
@@ -0,0 +1,16 @@
+{% extends "registration/base.html" %}
+{% load django_bootstrap5 %}
+{% block content %}
+
+{% endblock %}
From bbfc653f7ad35f5373230d096e717d9b35fb2962 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C2=AB=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9?=
<«dmitriy@bratkov.su»>
Date: Sat, 11 May 2024 23:45:32 +0300
Subject: [PATCH 2/8] =?UTF-8?q?=D0=A0=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7=D0=BE?=
=?UTF-8?q?=D0=B2=D0=B0=D0=BD=D0=B0=20=D0=BF=D1=80=D0=BE=D1=81=D1=82=D0=B0?=
=?UTF-8?q?=D1=8F=20=D1=84=D0=BE=D1=80=D0=BC=D0=B0=20=D1=80=D0=B5=D0=B3?=
=?UTF-8?q?=D0=B8=D1=81=D1=82=D1=80=D0=B0=D1=86=D0=B8=D0=B8=20=D0=BF=D0=BE?=
=?UTF-8?q?=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8F=20?=
=?UTF-8?q?=D0=B8=20=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD?=
=?UTF-8?q?=20Makefile=20=D0=B2=20=D1=80=D0=B0=D0=B7=D1=80=D0=B5=D0=B7?=
=?UTF-8?q?=D0=B5=20=D1=81=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8=D1=8F=20?=
=?UTF-8?q?=D1=81=D1=83=D0=BF=D0=B5=D1=80=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7?=
=?UTF-8?q?=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Makefile | 3 ++-
src/potential_user/forms.py | 4 +---
src/potential_user/models.py | 6 +++---
src/potential_user/urls.py | 4 +++-
src/potential_user/views.py | 17 ++++++++++++++++-
5 files changed, 25 insertions(+), 9 deletions(-)
diff --git a/Makefile b/Makefile
index cf681f7..8503b12 100644
--- a/Makefile
+++ b/Makefile
@@ -10,6 +10,7 @@ SHELL_YELLOW = \033[33m
SHELL_NC := \033[0m
ADMIN_NAME := admin
ADMIN_EMAIL := root@admin.ru
+PASSWORD := 123456
# Команда выполняемая по умолчанию.
@@ -51,7 +52,7 @@ makemigrations: migrate
# Создание супер-юзера.
createsuperuser:
- cd $(PROJECT_DIR) && $(DJANGO_RUN) createsuperuser --username $(ADMIN_NAME) --email $(ADMIN_EMAIL) --no-input
+ cd $(PROJECT_DIR) && $(DJANGO_RUN) createsuperuser --username $(ADMIN_NAME) --email $(ADMIN_EMAIL) --first_name admin --last_name root --phone +79881234567 --password $(PASSWORD) --no-input
# Запуск локального контейнера Postgres
diff --git a/src/potential_user/forms.py b/src/potential_user/forms.py
index 0bfbaa0..c30d732 100644
--- a/src/potential_user/forms.py
+++ b/src/potential_user/forms.py
@@ -1,5 +1,4 @@
from django import forms
-from phonenumber_field.formfields import PhoneNumberField
from .models import ApplicationForm
@@ -8,5 +7,4 @@ class RegistrationForm(forms.ModelForm):
class Meta:
model = ApplicationForm
- fields = {'telegram_id', 'name', 'surname', 'phone_number', 'city', }
-
+ fields = {'name', 'surname', 'phone_number', 'city', }
diff --git a/src/potential_user/models.py b/src/potential_user/models.py
index b0a27f6..6591bf4 100644
--- a/src/potential_user/models.py
+++ b/src/potential_user/models.py
@@ -9,13 +9,13 @@ class ApplicationForm(models.Model):
('teacher', 'Преподаватель'),
('student', 'Учащийся'),
)
-
- telegram_id = models.IntegerField('Telegram ID', unique=True, help_text='Введите свой ID')
+ # TODO Вернуть unique=True после реализации telegram_id
+ telegram_id = models.IntegerField('Telegram ID', help_text='Введите свой ID')
role = models.CharField('Роль', choices=ROLE_CHOICES, max_length=20)
name = models.CharField('Имя', max_length=20, help_text="Обязательное поле")
surname = models.CharField('Фамилия', max_length=20, help_text="Обязательное поле")
city = models.CharField('Город', max_length=20)
- phone_number = PhoneNumberField('Номер телефона')
+ phone_number = PhoneNumberField('Номер телефона', help_text='Формат +7XXXXXXXXXX')
approved = models.BooleanField(default=False)
class Meta:
diff --git a/src/potential_user/urls.py b/src/potential_user/urls.py
index e7691eb..84a9ccf 100644
--- a/src/potential_user/urls.py
+++ b/src/potential_user/urls.py
@@ -1,6 +1,6 @@
from django.urls import path
-from .views import RegistrationCreateView
+from .views import RegistrationCreateView, TemplateIndex
app_name = 'registration'
@@ -8,4 +8,6 @@
path('',
RegistrationCreateView.as_view(),
name='registration'),
+ # Временная индексная страница
+ path('', TemplateIndex.as_view(), name='index'),
]
diff --git a/src/potential_user/views.py b/src/potential_user/views.py
index bc05a6a..58aeced 100644
--- a/src/potential_user/views.py
+++ b/src/potential_user/views.py
@@ -1,4 +1,5 @@
-from django.views.generic import CreateView
+from django.views.generic import CreateView, ListView
+from django.urls import reverse_lazy
from .models import ApplicationForm
from .forms import RegistrationForm
@@ -9,3 +10,17 @@ class RegistrationCreateView(CreateView):
model = ApplicationForm
form_class = RegistrationForm
template_name = 'registration/registration_form.html'
+
+ # TODO убрать после реализации получения telegram_id
+ def form_valid(self, form):
+ form.instance.telegram_id = 12345678
+ return super().form_valid(form)
+
+ def get_success_url(self):
+ return reverse_lazy('registration:index')
+
+
+# TODO убрать после реализации главной страницы
+class TemplateIndex(ListView):
+ model = ApplicationForm
+ template_name = 'registration/fortest.html'
From 779a5563539745147cbcd2a6d4983206c0a47028 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C2=AB=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9?=
<«dmitriy@bratkov.su»>
Date: Sun, 12 May 2024 00:45:49 +0300
Subject: [PATCH 3/8] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB?=
=?UTF-8?q?=20=D0=B2=D1=80=D0=B5=D0=BC=D0=B5=D0=BD=D0=BD=D1=8B=D0=B9=20?=
=?UTF-8?q?=D0=B3=D0=B5=D0=BD=D0=B5=D1=80=D0=B0=D1=82=D0=BE=D1=80=20telegr?=
=?UTF-8?q?am=5Fid=20=D0=B8=20=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?=
=?UTF-8?q?=D0=BB=20=D0=B2=20=D0=BC=D0=BE=D0=B4=D0=B5=D0=BB=D0=B8=20Intege?=
=?UTF-8?q?r=20=D0=BD=D0=B0=20PositiveBigIntegerField?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/potential_user/models.py | 3 +--
src/potential_user/utils.py | 17 +++++++++++++++++
src/potential_user/views.py | 4 ++--
3 files changed, 20 insertions(+), 4 deletions(-)
create mode 100644 src/potential_user/utils.py
diff --git a/src/potential_user/models.py b/src/potential_user/models.py
index 6591bf4..ae5acf1 100644
--- a/src/potential_user/models.py
+++ b/src/potential_user/models.py
@@ -9,8 +9,7 @@ class ApplicationForm(models.Model):
('teacher', 'Преподаватель'),
('student', 'Учащийся'),
)
- # TODO Вернуть unique=True после реализации telegram_id
- telegram_id = models.IntegerField('Telegram ID', help_text='Введите свой ID')
+ telegram_id = models.PositiveBigIntegerField('Telegram ID', unique=True, help_text='Введите свой ID')
role = models.CharField('Роль', choices=ROLE_CHOICES, max_length=20)
name = models.CharField('Имя', max_length=20, help_text="Обязательное поле")
surname = models.CharField('Фамилия', max_length=20, help_text="Обязательное поле")
diff --git a/src/potential_user/utils.py b/src/potential_user/utils.py
new file mode 100644
index 0000000..0651679
--- /dev/null
+++ b/src/potential_user/utils.py
@@ -0,0 +1,17 @@
+import random
+import sys
+
+from .models import ApplicationForm
+
+
+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
diff --git a/src/potential_user/views.py b/src/potential_user/views.py
index 58aeced..d8e2750 100644
--- a/src/potential_user/views.py
+++ b/src/potential_user/views.py
@@ -3,7 +3,7 @@
from .models import ApplicationForm
from .forms import RegistrationForm
-
+from .utils import get_telegram_id
class RegistrationCreateView(CreateView):
@@ -13,7 +13,7 @@ class RegistrationCreateView(CreateView):
# TODO убрать после реализации получения telegram_id
def form_valid(self, form):
- form.instance.telegram_id = 12345678
+ form.instance.telegram_id = get_telegram_id()
return super().form_valid(form)
def get_success_url(self):
From 8a1914a30ea170476ebf5624cb5dd70219c5efff Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C2=AB=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9?=
<«dmitriy@bratkov.su»>
Date: Sun, 12 May 2024 01:09:35 +0300
Subject: [PATCH 4/8] Change for ruff
---
src/potential_user/forms.py | 2 ++
src/potential_user/models.py | 34 ++++++++++++++++++++++++++++------
src/potential_user/utils.py | 7 +++++--
src/potential_user/views.py | 14 ++++++++++----
4 files changed, 45 insertions(+), 12 deletions(-)
diff --git a/src/potential_user/forms.py b/src/potential_user/forms.py
index c30d732..f1cfe3b 100644
--- a/src/potential_user/forms.py
+++ b/src/potential_user/forms.py
@@ -4,7 +4,9 @@
class RegistrationForm(forms.ModelForm):
+ """Form to register a new user."""
class Meta:
+ """Form meta class."""
model = ApplicationForm
fields = {'name', 'surname', 'phone_number', 'city', }
diff --git a/src/potential_user/models.py b/src/potential_user/models.py
index ae5acf1..80398c0 100644
--- a/src/potential_user/models.py
+++ b/src/potential_user/models.py
@@ -9,12 +9,34 @@ class ApplicationForm(models.Model):
('teacher', 'Преподаватель'),
('student', 'Учащийся'),
)
- telegram_id = models.PositiveBigIntegerField('Telegram ID', unique=True, help_text='Введите свой ID')
- role = models.CharField('Роль', choices=ROLE_CHOICES, max_length=20)
- name = models.CharField('Имя', max_length=20, help_text="Обязательное поле")
- surname = models.CharField('Фамилия', max_length=20, help_text="Обязательное поле")
- city = models.CharField('Город', max_length=20)
- phone_number = PhoneNumberField('Номер телефона', help_text='Формат +7XXXXXXXXXX')
+ telegram_id = models.PositiveBigIntegerField(
+ 'Telegram ID',
+ unique=True,
+ help_text='Введите свой ID',
+ )
+ role = models.CharField(
+ 'Роль',
+ choices=ROLE_CHOICES,
+ max_length=20,
+ )
+ name = models.CharField(
+ 'Имя',
+ max_length=20,
+ help_text='Обязательное поле',
+ )
+ surname = models.CharField(
+ 'Фамилия',
+ max_length=20,
+ help_text='Обязательное поле',
+ )
+ city = models.CharField(
+ 'Город',
+ max_length=20,
+ )
+ phone_number = PhoneNumberField(
+ 'Номер телефона',
+ help_text='Формат +7XXXXXXXXXX',
+ )
approved = models.BooleanField(default=False)
class Meta:
diff --git a/src/potential_user/utils.py b/src/potential_user/utils.py
index 0651679..3b5710a 100644
--- a/src/potential_user/utils.py
+++ b/src/potential_user/utils.py
@@ -7,11 +7,14 @@
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()
+ tg_id_in_db = ApplicationForm.objects.filter(
+ telegram_id=telegram_id,
+ ).exists()
if tg_id_in_db:
continue
return telegram_id
diff --git a/src/potential_user/views.py b/src/potential_user/views.py
index d8e2750..6ebf7e2 100644
--- a/src/potential_user/views.py
+++ b/src/potential_user/views.py
@@ -1,11 +1,13 @@
-from django.views.generic import CreateView, ListView
from django.urls import reverse_lazy
+from django.views.generic import CreateView, ListView
-from .models import ApplicationForm
from .forms import RegistrationForm
+from .models import ApplicationForm
from .utils import get_telegram_id
+
class RegistrationCreateView(CreateView):
+ """Создает форму регистрации нового пользователя."""
model = ApplicationForm
form_class = RegistrationForm
@@ -13,14 +15,18 @@ class RegistrationCreateView(CreateView):
# 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:index')
# TODO убрать после реализации главной страницы
class TemplateIndex(ListView):
- model = ApplicationForm
- template_name = 'registration/fortest.html'
+ """Временная вьюха для регистрации."""
+
+ model = ApplicationForm
+ template_name = 'registration/fortest.html'
From e4f43593957207925654c651f8bf5ed7cafc8db7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C2=AB=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9?=
<«dmitriy@bratkov.su»>
Date: Sun, 12 May 2024 10:58:12 +0300
Subject: [PATCH 5/8] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?=
=?UTF-8?q?=D0=BB=20=D0=BF=D0=BE=20PEP=20forms.py?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/potential_user/forms.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/potential_user/forms.py b/src/potential_user/forms.py
index f1cfe3b..45c4662 100644
--- a/src/potential_user/forms.py
+++ b/src/potential_user/forms.py
@@ -8,5 +8,6 @@ class RegistrationForm(forms.ModelForm):
class Meta:
"""Form meta class."""
+
model = ApplicationForm
fields = {'name', 'surname', 'phone_number', 'city', }
From 3468ec3f282c31325740ca0ce6933f203667ff95 Mon Sep 17 00:00:00 2001
From: Konstantin Raikhert
Date: Mon, 13 May 2024 12:26:32 +0300
Subject: [PATCH 6/8] add django-bootstrap5 in poetry
---
poetry.lock | 36 +++++++++++++++++++++++++-----------
pyproject.toml | 2 +-
2 files changed, 26 insertions(+), 12 deletions(-)
diff --git a/poetry.lock b/poetry.lock
index 7479863..85eaa00 100644
--- a/poetry.lock
+++ b/poetry.lock
@@ -1,4 +1,4 @@
-# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand.
+# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand.
[[package]]
name = "anyio"
@@ -400,6 +400,20 @@ files = [
asgiref = ">=3,<4"
Django = ">=4.2,<5.0.0 || >5.0.0,<5.0.1 || >5.0.1,<5.0.2 || >5.0.2,<6"
+[[package]]
+name = "django-bootstrap5"
+version = "24.2"
+description = "Bootstrap 5 for Django"
+optional = false
+python-versions = ">=3.8"
+files = [
+ {file = "django_bootstrap5-24.2-py3-none-any.whl", hash = "sha256:6a5d83e9ff1952f7c07c54cebcb76c85f09787b8b57eeb4ec07554cd583acc64"},
+ {file = "django_bootstrap5-24.2.tar.gz", hash = "sha256:a3cee2b3d45745210c5b898af2917f310f44df746269fe09a93be28a0adc2a4b"},
+]
+
+[package.dependencies]
+Django = ">=4.2"
+
[[package]]
name = "django-environ"
version = "0.11.2"
@@ -935,28 +949,28 @@ files = [
[[package]]
name = "poetry-plugin-export"
-version = "1.7.1"
+version = "1.8.0"
description = "Poetry plugin to export the dependencies to various formats"
optional = false
-python-versions = ">=3.8,<4.0"
+python-versions = "<4.0,>=3.8"
files = [
- {file = "poetry_plugin_export-1.7.1-py3-none-any.whl", hash = "sha256:b2258e53ae0d369a73806f957ed0e726eb95c571a0ce8b1f273da686528cc1da"},
- {file = "poetry_plugin_export-1.7.1.tar.gz", hash = "sha256:cf62cfb6218a904290ba6db3bc1a24aa076d10f81c48c6e48b2ded430131e22e"},
+ {file = "poetry_plugin_export-1.8.0-py3-none-any.whl", hash = "sha256:adbe232cfa0cc04991ea3680c865cf748bff27593b9abcb1f35fb50ed7ba2c22"},
+ {file = "poetry_plugin_export-1.8.0.tar.gz", hash = "sha256:1fa6168a85d59395d835ca564bc19862a7c76061e60c3e7dfaec70d50937fc61"},
]
[package.dependencies]
-poetry = ">=1.8.0,<2.0.0"
-poetry-core = ">=1.7.0,<2.0.0"
+poetry = ">=1.8.0,<3.0.0"
+poetry-core = ">=1.7.0,<3.0.0"
[[package]]
name = "pre-commit"
-version = "3.7.0"
+version = "3.7.1"
description = "A framework for managing and maintaining multi-language pre-commit hooks."
optional = false
python-versions = ">=3.9"
files = [
- {file = "pre_commit-3.7.0-py2.py3-none-any.whl", hash = "sha256:5eae9e10c2b5ac51577c3452ec0a490455c45a0533f7960f993a0d01e59decab"},
- {file = "pre_commit-3.7.0.tar.gz", hash = "sha256:e209d61b8acdcf742404408531f0c37d49d2c734fd7cff2d6076083d191cb060"},
+ {file = "pre_commit-3.7.1-py2.py3-none-any.whl", hash = "sha256:fae36fd1d7ad7d6a5a1c0b0d5adb2ed1a3bda5a21bf6c3e5372073d7a11cd4c5"},
+ {file = "pre_commit-3.7.1.tar.gz", hash = "sha256:8ca3ad567bc78a4972a3f1a477e94a79d4597e8140a6e0b651c5e33899c3654a"},
]
[package.dependencies]
@@ -1486,4 +1500,4 @@ test = ["pytest"]
[metadata]
lock-version = "2.0"
python-versions = "^3.12"
-content-hash = "2680eb177cd6ce57f552dfa33c027a3ea08165a26a09bc3378090173ff590354"
+content-hash = "04f7f70f9a8c3a14b80f17bce92698b96331b5b3262b73cebd90bc9618616d62"
diff --git a/pyproject.toml b/pyproject.toml
index 71308e0..598ec18 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -14,6 +14,7 @@ poetry-plugin-export = "^1.7.1"
django-environ= "^0.11.2"
django-asgi-lifespan = "^0.3.1"
django-phonenumber-field = {extras = ["phonenumbers"], version = "^7.3.0"}
+django-bootstrap5 = "^24.2"
[tool.poetry.group.dev.dependencies]
@@ -115,4 +116,3 @@ inline-quotes = "single"
[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401"]
"settings*" = ["E501", "F405"]
-
From 9279b1eead2211efcb078a7da2bdda4aa92f8dac Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C2=AB=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9?=
<«dmitriy@bratkov.su»>
Date: Mon, 13 May 2024 13:42:51 +0300
Subject: [PATCH 7/8] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?=
=?UTF-8?q?=D0=B5=D0=BD=D1=8B=20=D0=BD=D0=B5=D0=B4=D0=BE=D1=87=D0=B5=D1=82?=
=?UTF-8?q?=D1=8B=20=D0=BF=D0=BE=20=D1=80=D0=B5=D0=B2=D1=8C=D1=8E?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/potential_user/forms.py | 2 +-
src/potential_user/urls.py | 4 +---
src/potential_user/utils.py | 4 ++--
src/potential_user/views.py | 18 +++++-------------
4 files changed, 9 insertions(+), 19 deletions(-)
diff --git a/src/potential_user/forms.py b/src/potential_user/forms.py
index 45c4662..2a66621 100644
--- a/src/potential_user/forms.py
+++ b/src/potential_user/forms.py
@@ -1,6 +1,6 @@
from django import forms
-from .models import ApplicationForm
+from potential_user.models import ApplicationForm
class RegistrationForm(forms.ModelForm):
diff --git a/src/potential_user/urls.py b/src/potential_user/urls.py
index 84a9ccf..1eae64e 100644
--- a/src/potential_user/urls.py
+++ b/src/potential_user/urls.py
@@ -1,6 +1,6 @@
from django.urls import path
-from .views import RegistrationCreateView, TemplateIndex
+from potential_user.views import RegistrationCreateView
app_name = 'registration'
@@ -8,6 +8,4 @@
path('',
RegistrationCreateView.as_view(),
name='registration'),
- # Временная индексная страница
- path('', TemplateIndex.as_view(), name='index'),
]
diff --git a/src/potential_user/utils.py b/src/potential_user/utils.py
index 3b5710a..c079825 100644
--- a/src/potential_user/utils.py
+++ b/src/potential_user/utils.py
@@ -1,9 +1,9 @@
import random
import sys
-from .models import ApplicationForm
-
+from potential_user.models import ApplicationForm
+#TODO Убрать после реализации хендлеров
def get_telegram_id() -> int:
"""
Получает телеграм id от бота.
diff --git a/src/potential_user/views.py b/src/potential_user/views.py
index 6ebf7e2..c5b2b89 100644
--- a/src/potential_user/views.py
+++ b/src/potential_user/views.py
@@ -1,9 +1,9 @@
from django.urls import reverse_lazy
-from django.views.generic import CreateView, ListView
+from django.views.generic import CreateView
-from .forms import RegistrationForm
-from .models import ApplicationForm
-from .utils import get_telegram_id
+from potential_user.forms import RegistrationForm
+from potential_user.models import ApplicationForm
+from potential_user.utils import get_telegram_id
class RegistrationCreateView(CreateView):
@@ -21,12 +21,4 @@ def form_valid(self, form):
def get_success_url(self):
"""Переадресовывет на главную страницу."""
- return reverse_lazy('registration:index')
-
-
-# TODO убрать после реализации главной страницы
-class TemplateIndex(ListView):
- """Временная вьюха для регистрации."""
-
- model = ApplicationForm
- template_name = 'registration/fortest.html'
+ return reverse_lazy('registration:registration')
From 10b063707b63af914c7602db724240ffda8f8950 Mon Sep 17 00:00:00 2001
From: Konstantin Raikhert
Date: Thu, 16 May 2024 12:04:26 +0300
Subject: [PATCH 8/8] new migrations in potential_user
---
Makefile | 2 +-
poetry.lock | 18 +++++++++---------
src/potential_user/migrations/0001_initial.py | 14 +++++++-------
src/potential_user/migrations/__init__.py | 0
4 files changed, 17 insertions(+), 17 deletions(-)
create mode 100644 src/potential_user/migrations/__init__.py
diff --git a/Makefile b/Makefile
index 5d65f08..94b235e 100644
--- a/Makefile
+++ b/Makefile
@@ -46,7 +46,7 @@ migrate:
# Создание новых миграций на основе сформированных моделей.
makemigrations:
- cd $(PROJECT_DIR) && $(DJANGO_RUN) makemigrations --no-input
+ cd $(PROJECT_DIR) && $(DJANGO_RUN) makemigrations
# Создание супер-юзера.
diff --git a/poetry.lock b/poetry.lock
index 85eaa00..694de7f 100644
--- a/poetry.lock
+++ b/poetry.lock
@@ -556,13 +556,13 @@ doc = ["Sphinx", "sphinx-rtd-theme", "sphinxcontrib-spelling"]
[[package]]
name = "faker"
-version = "25.1.0"
+version = "25.2.0"
description = "Faker is a Python package that generates fake data for you."
optional = false
python-versions = ">=3.8"
files = [
- {file = "Faker-25.1.0-py3-none-any.whl", hash = "sha256:24e28dce0b89683bb9e017e042b971c8c4909cff551b6d46f1e207674c7c2526"},
- {file = "Faker-25.1.0.tar.gz", hash = "sha256:2107618cf306bb188dcfea3e5cfd94aa92d65c7293a2437c1e96a99c83274755"},
+ {file = "Faker-25.2.0-py3-none-any.whl", hash = "sha256:cfe97c4857c4c36ee32ea4aaabef884895992e209bae4cbd26807cf3e05c6918"},
+ {file = "Faker-25.2.0.tar.gz", hash = "sha256:45b84f47ff1ef86e3d1a8d11583ca871ecf6730fad0660edadc02576583a2423"},
]
[package.dependencies]
@@ -887,13 +887,13 @@ testing = ["pytest", "pytest-cov", "wheel"]
[[package]]
name = "platformdirs"
-version = "4.2.1"
+version = "4.2.2"
description = "A small Python package for determining appropriate platform-specific dirs, e.g. a `user data dir`."
optional = false
python-versions = ">=3.8"
files = [
- {file = "platformdirs-4.2.1-py3-none-any.whl", hash = "sha256:17d5a1161b3fd67b390023cb2d3b026bbd40abde6fdb052dfbd3a29c3ba22ee1"},
- {file = "platformdirs-4.2.1.tar.gz", hash = "sha256:031cd18d4ec63ec53e82dceaac0417d218a6863f7745dfcc9efe7793b7039bdf"},
+ {file = "platformdirs-4.2.2-py3-none-any.whl", hash = "sha256:2d7a1657e36a80ea911db832a8a6ece5ee53d8de21edd5cc5879af6530b1bfee"},
+ {file = "platformdirs-4.2.2.tar.gz", hash = "sha256:38b7b51f512eed9e84a22788b4bce1de17c0adb134d6becb09836e37d8654cd3"},
]
[package.extras]
@@ -1406,13 +1406,13 @@ zstd = ["zstandard (>=0.18.0)"]
[[package]]
name = "virtualenv"
-version = "20.26.1"
+version = "20.26.2"
description = "Virtual Python Environment builder"
optional = false
python-versions = ">=3.7"
files = [
- {file = "virtualenv-20.26.1-py3-none-any.whl", hash = "sha256:7aa9982a728ae5892558bff6a2839c00b9ed145523ece2274fad6f414690ae75"},
- {file = "virtualenv-20.26.1.tar.gz", hash = "sha256:604bfdceaeece392802e6ae48e69cec49168b9c5f4a44e483963f9242eb0e78b"},
+ {file = "virtualenv-20.26.2-py3-none-any.whl", hash = "sha256:a624db5e94f01ad993d476b9ee5346fdf7b9de43ccaee0e0197012dc838a0e9b"},
+ {file = "virtualenv-20.26.2.tar.gz", hash = "sha256:82bf0f4eebbb78d36ddaee0283d43fe5736b53880b8a8cdcd37390a07ac3741c"},
]
[package.dependencies]
diff --git a/src/potential_user/migrations/0001_initial.py b/src/potential_user/migrations/0001_initial.py
index 2c2be3f..334b6c6 100644
--- a/src/potential_user/migrations/0001_initial.py
+++ b/src/potential_user/migrations/0001_initial.py
@@ -1,4 +1,4 @@
-# Generated by Django 5.0.4 on 2024-05-10 18:48
+# Generated by Django 5.0.6 on 2024-05-16 08:59
import phonenumber_field.modelfields
from django.db import migrations, models
@@ -16,12 +16,12 @@ class Migration(migrations.Migration):
name='ApplicationForm',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
- ('telegram_id', models.IntegerField(unique=True, verbose_name='Telegram ID')),
- ('role', models.CharField(choices=[('teacher', 'Преподаватель'), ('student', 'Учащийся')], max_length=20)),
- ('name', models.CharField(max_length=20)),
- ('surname', models.CharField(max_length=20)),
- ('city', models.CharField(max_length=20)),
- ('phone_number', phonenumber_field.modelfields.PhoneNumberField(max_length=128, region=None)),
+ ('telegram_id', models.PositiveBigIntegerField(help_text='Введите свой ID', unique=True, verbose_name='Telegram ID')),
+ ('role', models.CharField(choices=[('teacher', 'Преподаватель'), ('student', 'Учащийся')], max_length=20, verbose_name='Роль')),
+ ('name', models.CharField(help_text='Обязательное поле', max_length=20, verbose_name='Имя')),
+ ('surname', models.CharField(help_text='Обязательное поле', max_length=20, verbose_name='Фамилия')),
+ ('city', models.CharField(max_length=20, verbose_name='Город')),
+ ('phone_number', phonenumber_field.modelfields.PhoneNumberField(help_text='Формат +7XXXXXXXXXX', max_length=128, region=None, verbose_name='Номер телефона')),
('approved', models.BooleanField(default=False)),
],
options={
diff --git a/src/potential_user/migrations/__init__.py b/src/potential_user/migrations/__init__.py
new file mode 100644
index 0000000..e69de29