Skip to content

Commit

Permalink
Merge pull request #23 from Pet-projects-CodePET/features/description…
Browse files Browse the repository at this point in the history
…_of_sections

Features/description of sections
  • Loading branch information
Nadya2502 authored Feb 14, 2024
2 parents 9b2b4e8 + abe173b commit 44ed0bb
Show file tree
Hide file tree
Showing 9 changed files with 104 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ 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

Expand Down
6 changes: 6 additions & 0 deletions src/backend/apps/general/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class GeneralConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "apps.general"
2 changes: 2 additions & 0 deletions src/backend/apps/general/constants.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
TITLE_LENGTH = 100
DESCRIPRION_LENGTH = 250
MAX_LENGTH_EMAIL = 256
EMAIL_HELP_TEXT = (
"Допускается локальная часть 2 - 192 символа, доменная часть 3 - 63 "
Expand Down
38 changes: 38 additions & 0 deletions src/backend/apps/general/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Generated by Django 5.0.1 on 2024-02-08 22:41

from django.db import migrations, models


class Migration(migrations.Migration):
initial = True

dependencies = [
migrations.swappable_dependency(),
]



operations = [
migrations.CreateModel(
name="Section",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"title",
models.TextField(max_length=55, verbose_name="Заголовок"),
),
(
"description",
models.TextField(max_length=160, verbose_name="Текст"),
),
],
),
]
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="Заголовок"),
),
]
Empty file.
16 changes: 16 additions & 0 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 @@ -11,3 +13,17 @@ class CreatedModifiedFields(models.Model):

class Meta:
abstract = True


class Section(models.Model):
"""Секции на главной странице"""

title = models.TextField(
verbose_name="Заголовок", max_length=TITLE_LENGTH, null=False
)
description = models.TextField(
verbose_name="Текст", max_length=DESCRIPRION_LENGTH, null=False
)

def __str__(self):
return self.title
9 changes: 9 additions & 0 deletions src/backend/apps/general/serializers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from rest_framework import serializers

from .models import Section


class SectionSerializer(serializers.ModelSerializer):
class Meta:
model = Section
fields = "__all__"
9 changes: 9 additions & 0 deletions src/backend/apps/general/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from rest_framework import generics

from .models import Section
from .serializers import SectionSerializer


class SectionAPIList(generics.RetrieveAPIView, generics.ListAPIView):
queryset = Section.objects.all()
serializer_class = SectionSerializer

0 comments on commit 44ed0bb

Please sign in to comment.