diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0bf5a4d..0a2503d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,18 +13,18 @@ repos: - id: check-merge-conflict - repo: https://github.com/psf/black-pre-commit-mirror - rev: 23.12.1 + rev: 24.1.1 hooks: - id: black language_version: python3.12.1 exclude: migrations - repo: https://github.com/PyCQA/isort - rev: 5.12.0 + rev: 5.13.2 hooks: - id: isort - repo: https://github.com/pre-commit/mirrors-mypy - rev: "" + rev: "v1.8.0" hooks: - id: mypy diff --git a/src/backend/apps/general/constants.py b/src/backend/apps/general/constants.py new file mode 100644 index 0000000..274e629 --- /dev/null +++ b/src/backend/apps/general/constants.py @@ -0,0 +1,2 @@ +TITLE_LENGTH = 100 +DESCRIPRION_LENGTH = 250 diff --git a/src/backend/apps/general/migrations/0002_alter_section_description_alter_section_title.py b/src/backend/apps/general/migrations/0002_alter_section_description_alter_section_title.py new file mode 100644 index 0000000..a894e95 --- /dev/null +++ b/src/backend/apps/general/migrations/0002_alter_section_description_alter_section_title.py @@ -0,0 +1,22 @@ +# Generated by Django 5.0.1 on 2024-02-12 13:40 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("general", "0001_initial"), + ] + + operations = [ + migrations.AlterField( + model_name="section", + name="description", + field=models.TextField(max_length=250, verbose_name="Текст"), + ), + migrations.AlterField( + model_name="section", + name="title", + field=models.TextField(max_length=100, verbose_name="Заголовок"), + ), + ] diff --git a/src/backend/apps/general/models.py b/src/backend/apps/general/models.py index 725695c..c8ae9b0 100644 --- a/src/backend/apps/general/models.py +++ b/src/backend/apps/general/models.py @@ -1,5 +1,7 @@ from django.db import models +from .constants import DESCRIPRION_LENGTH, TITLE_LENGTH + class CreatedModifiedFields(models.Model): """Базовая модель.""" @@ -15,10 +17,10 @@ class Section(models.Model): """Секции на главной странице""" title = models.TextField( - verbose_name="Заголовок", max_length=55, null=False + verbose_name="Заголовок", max_length=TITLE_LENGTH, null=False ) description = models.TextField( - verbose_name="Текст", max_length=160, null=False + verbose_name="Текст", max_length=DESCRIPRION_LENGTH, null=False ) def __str__(self): diff --git a/src/backend/apps/general/views.py b/src/backend/apps/general/views.py index 07c50de..76ea9cb 100644 --- a/src/backend/apps/general/views.py +++ b/src/backend/apps/general/views.py @@ -4,6 +4,6 @@ from .serializers import SectionSerializer -class SectionAPIList(generics.RetrieveAPIView): +class SectionAPIList(generics.RetrieveAPIView, generics.ListAPIView): queryset = Section.objects.all() serializer_class = SectionSerializer