From 6311993b14a3b74189096571515c40d3453c2a26 Mon Sep 17 00:00:00 2001 From: Egor fureunoir Gorbunov Date: Sun, 15 Feb 2026 03:06:17 +0300 Subject: [PATCH] refactor(core): improve type checking and fix password handling in demo data Replaced `pyright:ignore` with `ty:ignore` for better compatibility and accuracy in type annotations. Removed inline passwords during user creation and updated logic to securely set and save passwords afterward. --- engine/core/management/commands/demo_data.py | 10 +++++----- engine/core/views.py | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/engine/core/management/commands/demo_data.py b/engine/core/management/commands/demo_data.py index 89cced28..fda90940 100644 --- a/engine/core/management/commands/demo_data.py +++ b/engine/core/management/commands/demo_data.py @@ -97,7 +97,6 @@ class Command(BaseCommand): def staff_user(self): user, _ = User.objects.get_or_create( email=f"staff@{DEMO_EMAIL_DOMAIN}", - password="Staff!Demo888", first_name="Alice", last_name="Schon", is_staff=True, @@ -106,6 +105,7 @@ class Command(BaseCommand): ) if _: user.set_password("Staff!Demo888") + user.save() if not user.groups.filter(name="E-Commerce Admin").exists(): user.groups.add(Group.objects.get(name="E-Commerce Admin")) return user @@ -114,7 +114,6 @@ class Command(BaseCommand): def super_user(self): user, _ = User.objects.get_or_create( email=f"super@{DEMO_EMAIL_DOMAIN}", - password="Super!Demo888", first_name="Bob", last_name="Schon", is_superuser=True, @@ -124,6 +123,7 @@ class Command(BaseCommand): ) if _: user.set_password("Super!Demo888") + user.save() return user def _load_demo_data(self) -> None: @@ -644,11 +644,11 @@ class Command(BaseCommand): is_static_page=post_data.get("is_static_page", False), ) if "title_ru" in post_data: - post.title_ru_ru = post_data["title_ru"] + post.title_ru_ru = post_data["title_ru"] # ty:ignore[unresolved-attribute] if content_ru: - post.content_ru_ru = content_ru + post.content_ru_ru = content_ru # ty:ignore[unresolved-attribute] if "meta_description_ru" in post_data: - post.meta_description_ru_ru = post_data["meta_description_ru"] + post.meta_description_ru_ru = post_data["meta_description_ru"] # ty:ignore[unresolved-attribute] post.save() for tag_name in post_data.get("tags", []): diff --git a/engine/core/views.py b/engine/core/views.py index 7f1b6cde..908acc41 100644 --- a/engine/core/views.py +++ b/engine/core/views.py @@ -97,7 +97,7 @@ def sitemap_index(request, *args, **kwargs): # noinspection PyTypeChecker -sitemap_index.__doc__ = _( # pyright: ignore[reportUnknownVariableType] +sitemap_index.__doc__ = _( # ty:ignore[invalid-assignment] "Handles the request for the sitemap index and returns an XML response. " "It ensures the response includes the appropriate content type header for XML." ) @@ -112,7 +112,7 @@ def sitemap_detail(request, *args, **kwargs): # noinspection PyTypeChecker -sitemap_detail.__doc__ = _( # pyright: ignore[reportUnknownVariableType] +sitemap_detail.__doc__ = _( # ty:ignore[invalid-assignment] "Handles the detailed view response for a sitemap. " "This function processes the request, fetches the appropriate " "sitemap detail response, and sets the Content-Type header for XML."