Skip to content

Commit

Permalink
[*] Conflicts. R: Conflicts in code versions. FB: Resolve conflicts.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtemKAF committed Apr 1, 2024
2 parents 95eb6ff + 3b5cbc3 commit 309b11d
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/backend/api/v1/projects/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


class DirectionSerializer(serializers.ModelSerializer):
"""Сериализатор специалиста."""
"""Сериализатор направления разработки."""

class Meta:
model = Direction
Expand Down
2 changes: 1 addition & 1 deletion src/backend/apps/general/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
MIN_LENGTH_SPECIALIZATION_NAME = 2
LENGTH_SPECIALIZATION_NAME_ERROR_TEXT = (
f"Длина поля от {MIN_LENGTH_SPECIALIZATION_NAME} до "
f"{MIN_LENGTH_SPECIALIZATION_NAME} символов."
f"{MAX_LENGTH_SPECIALIZATION_NAME} символов."
)
REGEX_SPECIALIZATION_NAME = r"(^[A-Za-zА-Яа-яЁё\s\/]+)\Z"
REGEX_SPECIALIZATION_NAME_ERROR_TEXT = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Migration(migrations.Migration):
max_length=100,
validators=[
django.core.validators.MinLengthValidator(
limit_value=2, message="Длина поля от 2 до 2 символов."
limit_value=2, message="Длина поля от 2 до 100 символов."
),
django.core.validators.RegexValidator(
message="Специализация может содержать: кириллические и латинские символы,пробелы и символ /",
Expand Down
5 changes: 5 additions & 0 deletions src/backend/apps/projects/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@
class ProjectConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "apps.projects"

def ready(self):
from . import signals # noqa: F401,

return super().ready()
5 changes: 2 additions & 3 deletions src/backend/apps/projects/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
MAX_LENGTH_DIRECTION_NAME = 20
MIN_LENGTH_DIRECTION_NAME = 2
LENGTH_DIRECTION_NAME_ERROR_TEXT = (
f"Длина поля от {MIN_LENGTH_PROJECT_NAME} до {MAX_LENGTH_PROJECT_NAME} "
"символов."
f"Длина поля от {MIN_LENGTH_DIRECTION_NAME} до "
f"{MAX_LENGTH_DIRECTION_NAME} символов."
)
REGEX_DIRECTION_NAME = r"(^[A-Za-zА-Яа-яЁё]+)\Z"
REGEX_DIRECTION_NAME_ERROR_TEXT = (
Expand All @@ -47,5 +47,4 @@
(3, "Черновик"),
)


PROJECTS_PER_PAGE = 10
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Generated by Django 5.0.1 on 2024-03-27 19:19

import django.core.validators
from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("general", "0002_alter_specialist_specialization_and_more"),
("projects", "0002_alter_project_busyness"),
]

operations = [
migrations.AlterField(
model_name="direction",
name="name",
field=models.CharField(
max_length=20,
unique=True,
validators=[
django.core.validators.MinLengthValidator(
limit_value=2,
message="Длина поля от 2 до 20 символов.",
),
django.core.validators.RegexValidator(
message="Направление разработки может содержать: кириллические и латинские символы.",
regex="(^[A-Za-zА-Яа-яЁё]+)\\Z",
),
],
verbose_name="Название",
),
),
migrations.AddConstraint(
model_name="projectspecialist",
constraint=models.UniqueConstraint(
fields=("project", "specialist", "level"),
name="projects_projectspecialist_unique_specialist_per_project",
),
),
]
6 changes: 6 additions & 0 deletions src/backend/apps/projects/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,9 @@ class Meta:
verbose_name = "Специалист проекта"
verbose_name_plural = "Специалисты проекта"
default_related_name = "project_specialists"
constraints = (
models.UniqueConstraint(
fields=("project", "specialist", "level"),
name="%(app_label)s_%(class)s_unique_specialist_per_project",
),
)
13 changes: 13 additions & 0 deletions src/backend/apps/projects/signals.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from django.db.models.signals import post_save
from django.dispatch import receiver

from apps.projects.models import Project


@receiver(post_save, sender=Project)
def create_user_profile(sender, instance, created, **kwargs):
"""Метод присвоения статуса is_organizer пользователю."""

if created and not instance.creator.is_organizer:
instance.creator.is_organizer = True
instance.creator.save()

0 comments on commit 309b11d

Please sign in to comment.