Skip to content
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

Added AUTH_USER_MODEL in settings and few naming fixes #32

Merged
merged 2 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ python-telegram-bot = "^21.1.1"
poetry-plugin-export = "^1.7.1"
django-environ= "^0.11.2"
django-asgi-lifespan = "^0.3.1"
django-phonenumber-field = "^7.3.0"
django-phonenumber-field = {extras = ["phonenumbers"], version = "^7.3.0"}

[tool.poetry.group.dev.dependencies]
ruff = "^0.4.2"
Expand Down
10 changes: 5 additions & 5 deletions src/admin_user/admin.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin

from admin_user.models import Administator
from admin_user.models import Administrator


@admin.register(Administator)
class AdministatorAdmin(UserAdmin):
@admin.register(Administrator)
class AdministratorAdmin(UserAdmin):
"""Admin panel for the Admin model in the Django admin area.

Changes made:
Expand All @@ -17,8 +17,8 @@ class AdministatorAdmin(UserAdmin):
add_fieldsets = (
(None, {
"fields": (
Administator.USERNAME_FIELD,
*Administator.REQUIRED_FIELDS,
Administrator.USERNAME_FIELD,
*Administrator.REQUIRED_FIELDS,
"password1",
"password2",
"is_staff",
Expand Down
4 changes: 2 additions & 2 deletions src/admin_user/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
EMAIL_LENGTH = 254


class Administator(AbstractUser):
"""Custom administator model."""
class Administrator(AbstractUser):
"""Custom Administrator model."""

first_name = models.CharField("Имя", max_length=DEFAULT_NAME_LENGTH)
last_name = models.CharField("Фамилия", max_length=DEFAULT_NAME_LENGTH)
Expand Down
14 changes: 8 additions & 6 deletions src/bot/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ def stop_bot(self, **kwargs):
def ready(self) -> None:
"""Perform actions when the application is ready."""
import os

# TODO: временное решение, необходимо продумать улучшение.
if os.environ.get("DJANGO_MIGRATE", False):
if os.environ.get("RUN_MAIN", None) != "true":
from bot.bot_interface import Bot

if os.environ.get("RUN_MAIN", None) != "true":
from bot.bot_interface import Bot
self.bot = Bot()

self.bot = Bot()
asgi_shutdown.connect(self.stop_bot)

asgi_shutdown.connect(self.stop_bot)

self.bot.start()
self.bot.start()
4 changes: 3 additions & 1 deletion src/core/config/settings_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"schooling.apps.SchoolingConfig",
]

EXTERNAL_APPS = []
EXTERNAL_APPS = ["phonenumber_field",]

INSTALLED_APPS = DEFAULT_APPS + EXTERNAL_APPS + LOCAL_APPS

Expand Down Expand Up @@ -71,6 +71,8 @@

WSGI_APPLICATION = "core.wsgi.application"

AUTH_USER_MODEL = "admin_user.Administrator"

AUTH_PASSWORD_VALIDATORS = [
{
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
Expand Down
2 changes: 1 addition & 1 deletion src/potential_user/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ApplicationForm(models.Model):
)

telegram_id = models.IntegerField("Telegram ID", unique=True)
role = models.CharField(choices=ROLE_CHOICES)
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)
Expand Down
Loading