Skip to content

Commit

Permalink
Merge pull request #21 from Pet-projects-CodePET/feature/add-project-…
Browse files Browse the repository at this point in the history
…model

feat:add project models
  • Loading branch information
olees-orlenko authored Feb 13, 2024
2 parents 2d2f957 + 53c737d commit 35c76a9
Show file tree
Hide file tree
Showing 12 changed files with 626 additions and 1 deletion.
Empty file.
54 changes: 54 additions & 0 deletions src/backend/apps/project/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
from django.contrib import admin

from .constants import LIST_PER_PAGE
from .models import Level, Project, Skill, Specialist, Specialization, Status


@admin.register(Skill)
class SkillAdmin(admin.ModelAdmin):
list_display = ("name",)
search_fields = ("name",)


@admin.register(Status)
class StatusAdmin(admin.ModelAdmin):
list_display = ("name",)
search_fields = ("name",)


@admin.register(Level)
class LevelAdmin(admin.ModelAdmin):
list_display = ("name",)
search_fields = ("name",)


@admin.register(Specialist)
class SpecialistAdmin(admin.ModelAdmin):
list_display = ("name", "specialization")
list_filter = ("specialization",)
search_fields = ("name", "specialization__name")


@admin.register(Specialization)
class SpecializationAdmin(admin.ModelAdmin):
list_display = ("name",)
search_fields = ("name",)


@admin.register(Project)
class ProjectAdmin(admin.ModelAdmin):
list_display = (
"name",
"creator",
"started",
"ended",
"contacts",
"level",
"busyness",
"recruitment_status",
"status",
"direction",
)
list_filter = ("level", "busyness", "status")
search_fields = ("name", "description", "purpose", "creator__username")
list_per_page = LIST_PER_PAGE
6 changes: 6 additions & 0 deletions src/backend/apps/project/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class ProjectConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "apps.project"
19 changes: 19 additions & 0 deletions src/backend/apps/project/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
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
STATUS_CHOICES = [
(1, "Набор открыт"),
(2, "Набор закрыт"),
]
243 changes: 243 additions & 0 deletions src/backend/apps/project/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,243 @@
# Generated by Django 5.0.1 on 2024-02-05 12:04

import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):
initial = True

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.CreateModel(
name="Level",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"name",
models.CharField(max_length=100, verbose_name="Название"),
),
],
options={
"verbose_name": "Уровень",
"verbose_name_plural": "Уровни",
},
),
migrations.CreateModel(
name="Skill",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"name",
models.CharField(max_length=100, verbose_name="Название"),
),
],
options={
"verbose_name": "Навык",
"verbose_name_plural": "Навыки",
},
),
migrations.CreateModel(
name="Specialization",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"name",
models.CharField(max_length=100, verbose_name="Название"),
),
("quantity", models.PositiveSmallIntegerField()),
],
options={
"verbose_name": "Специальность",
"verbose_name_plural": "Специальности",
},
),
migrations.CreateModel(
name="Status",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"name",
models.CharField(max_length=100, verbose_name="Название"),
),
],
options={
"verbose_name": "Статус",
"verbose_name_plural": "Статусы",
},
),
migrations.CreateModel(
name="Specialist",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"name",
models.CharField(max_length=100, verbose_name="Название"),
),
(
"specialization",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="specialists",
to="project.specialization",
verbose_name="Специализация",
),
),
],
options={
"verbose_name": "Специальность",
"verbose_name_plural": "Специальности",
},
),
migrations.CreateModel(
name="Project",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("created", models.DateTimeField(auto_now_add=True)),
("modified", models.DateTimeField(auto_now=True)),
(
"name",
models.CharField(
max_length=100, verbose_name="Название проекта"
),
),
(
"description",
models.TextField(
max_length=3000, verbose_name="Описание проекта"
),
),
(
"purpose",
models.CharField(
max_length=100, verbose_name="Цель проекта"
),
),
(
"started",
models.DateField(
blank=True,
null=True,
verbose_name="Дата начала проекта",
),
),
(
"ended",
models.DateField(
blank=True,
null=True,
verbose_name="Дата окончания проекта",
),
),
(
"busyness",
models.CharField(
choices=[
("full_time", "Полная занятость"),
("part_time", "Частичная занятость"),
],
max_length=20,
verbose_name="Занятость",
),
),
(
"creator",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="projects",
to=settings.AUTH_USER_MODEL,
verbose_name="Организатор",
),
),
(
"level",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="project.level",
verbose_name="Уровень",
),
),
(
"skills",
models.ManyToManyField(
related_name="projects",
to="project.skill",
verbose_name="Навыки",
),
),
(
"specialists",
models.ManyToManyField(
related_name="projects",
to="project.specialist",
verbose_name="Специалисты",
),
),
(
"status",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="project.status",
verbose_name="Статус",
),
),
],
options={
"verbose_name": "Проект",
"verbose_name_plural": "Проекты",
"ordering": ("-created",),
},
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Generated by Django 5.0.1 on 2024-02-07 14:24

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("project", "0001_initial"),
]

operations = [
migrations.AlterModelOptions(
name="specialist",
options={
"verbose_name": "Специалист",
"verbose_name_plural": "Специалисты",
},
),
migrations.AlterField(
model_name="project",
name="busyness",
field=models.IntegerField(
choices=[(1, "Полная занятость"), (2, "Частичная занятость")],
verbose_name="Занятость",
),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Generated by Django 5.0.1 on 2024-02-07 15:28

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("project", "0002_alter_specialist_options_alter_project_busyness"),
]

operations = [
migrations.AddField(
model_name="project",
name="recruitment_status",
field=models.IntegerField(
choices=[(1, "Набор открыт"), (2, "Набор закрыт")],
default=1,
verbose_name="Статус набора участников",
),
),
migrations.AlterField(
model_name="project",
name="status",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="project.status",
verbose_name="Статус проекта",
),
),
]
Loading

0 comments on commit 35c76a9

Please sign in to comment.