diff --git a/src/backend/apps/project/admin.py b/src/backend/apps/project/admin.py index 0cd6539..3e21395 100644 --- a/src/backend/apps/project/admin.py +++ b/src/backend/apps/project/admin.py @@ -42,18 +42,13 @@ class ProjectAdmin(admin.ModelAdmin): "creator", "started", "ended", - "duration", + "contacts", "level", "busyness", "recruitment_status", "status", + "direction", ) list_filter = ("level", "busyness", "status") search_fields = ("name", "description", "purpose", "creator__username") - readonly_fields = ("duration",) list_per_page = LIST_PER_PAGE - - def duration(self, instance): - return instance.duration - - duration.short_description = "Продолжительность в днях" diff --git a/src/backend/apps/project/constants.py b/src/backend/apps/project/constants.py index e10495d..77309e2 100644 --- a/src/backend/apps/project/constants.py +++ b/src/backend/apps/project/constants.py @@ -1,3 +1,15 @@ +BUSYNESS_CHOICES = [ + (1, "10"), + (2, "20"), + (3, "30"), + (4, "40"), +] +CONTACTS_LENGTH = 256 +DIRECTION_CHOICES = [ + (1, "Десктоп"), + (2, "Веб"), + (3, "Мобильная"), +] DESCRIPTION_LENGTH = 3000 LIST_PER_PAGE = 10 NAME_LENGTH = 100 diff --git a/src/backend/apps/project/migrations/0005_alter_specialization_options_and_more.py b/src/backend/apps/project/migrations/0005_alter_specialization_options_and_more.py new file mode 100644 index 0000000..06711df --- /dev/null +++ b/src/backend/apps/project/migrations/0005_alter_specialization_options_and_more.py @@ -0,0 +1,60 @@ +# Generated by Django 5.0.1 on 2024-02-12 13:23 + +from django.conf import settings +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("project", "0004_alter_project_busyness"), + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.AlterModelOptions( + name="specialization", + options={ + "verbose_name": "Специализация", + "verbose_name_plural": "Специализации", + }, + ), + migrations.RemoveField( + model_name="specialization", + name="quantity", + ), + migrations.AddField( + model_name="project", + name="contacts", + field=models.TextField( + default="", max_length=256, verbose_name="Контакты для связи" + ), + preserve_default=False, + ), + migrations.AddField( + model_name="project", + name="direction", + field=models.IntegerField( + choices=[(1, "Десктоп"), (2, "Веб"), (3, "Мобильная")], + default=1, + verbose_name="Направление разработки", + ), + preserve_default=False, + ), + migrations.AddField( + model_name="project", + name="participants", + field=models.ManyToManyField( + related_name="project_participants", + to=settings.AUTH_USER_MODEL, + verbose_name="Команда проекта", + ), + ), + migrations.AlterField( + model_name="project", + name="busyness", + field=models.IntegerField( + choices=[(1, "10"), (2, "20"), (3, "30"), (4, "40")], + verbose_name="Занятость в часах в неделю", + ), + ), + ] diff --git a/src/backend/apps/project/models.py b/src/backend/apps/project/models.py index 9f3eb0b..6f21b7c 100644 --- a/src/backend/apps/project/models.py +++ b/src/backend/apps/project/models.py @@ -3,7 +3,14 @@ from apps.general.models import CreatedModifiedFields -from .constants import DESCRIPTION_LENGTH, NAME_LENGTH, STATUS_CHOICES +from .constants import ( + BUSYNESS_CHOICES, + CONTACTS_LENGTH, + DESCRIPTION_LENGTH, + DIRECTION_CHOICES, + NAME_LENGTH, + STATUS_CHOICES, +) User = get_user_model() @@ -14,11 +21,10 @@ class Specialization(models.Model): """ name = models.CharField("Название", max_length=NAME_LENGTH) - quantity = models.PositiveSmallIntegerField() class Meta: - verbose_name = "Специальность" - verbose_name_plural = "Специальности" + verbose_name = "Специализация" + verbose_name_plural = "Специализации" def __str__(self) -> str: return self.name @@ -124,6 +130,7 @@ class Project(CreatedModifiedFields): verbose_name="Навыки", ) busyness = models.IntegerField( + choices=BUSYNESS_CHOICES, verbose_name="Занятость в часах в неделю", ) recruitment_status = models.IntegerField( @@ -136,18 +143,20 @@ class Project(CreatedModifiedFields): on_delete=models.CASCADE, verbose_name="Статус проекта", ) - - @property - def duration(self): - """ - Вычисляет и возвращает продолжительность проекта в днях. - """ - if self.ended is not None and self.started is not None: - duration = self.ended - self.started - return duration.days - return None - - duration.fget.short_description = "Продолжительность" + contacts = models.TextField( + "Контакты для связи", max_length=CONTACTS_LENGTH + ) + direction = models.IntegerField( + choices=DIRECTION_CHOICES, + verbose_name="Направление разработки", + # default=1, + ) + participants = models.ManyToManyField( + User, + # through="Participant", + related_name="project_participants", + verbose_name="Команда проекта", + ) class Meta: verbose_name = "Проект"