Skip to content

Commit

Permalink
[~] Поправила реализацию SectionAPIList (добавила generics.ListAPIVie…
Browse files Browse the repository at this point in the history
…w), убрала max_length в константы
  • Loading branch information
Nadya2502 committed Feb 12, 2024
1 parent 7bca28d commit 566c0af
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 6 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions src/backend/apps/general/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
TITLE_LENGTH = 100
DESCRIPRION_LENGTH = 250
Original file line number Diff line number Diff line change
@@ -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="Заголовок"),
),
]
6 changes: 4 additions & 2 deletions src/backend/apps/general/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from django.db import models

from .constants import DESCRIPRION_LENGTH, TITLE_LENGTH


class CreatedModifiedFields(models.Model):
"""Базовая модель."""
Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion src/backend/apps/general/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 566c0af

Please sign in to comment.