Skip to content

Commit 44b2d84

Browse files
authored
Merge pull request #541 from PROCOLLAB-github/feature/update_program_model
Feature/update program model
2 parents 863aabe + ef7eeaa commit 44b2d84

13 files changed

Lines changed: 162 additions & 96 deletions

invites/tests.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ def setUp(self) -> None:
3636
"name": "Test",
3737
"description": "Test",
3838
"industry": Industry.objects.create(name="Test").id,
39-
"step": 1,
4039
"draft": False,
4140
}
4241

projects/admin.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,21 @@ class ProjectAdmin(admin.ModelAdmin):
1818
"name",
1919
"draft",
2020
"is_company",
21-
"track",
22-
"direction",
21+
"trl",
22+
"target_audience",
23+
"implementation_deadline",
2324
)
2425
list_display_links = (
2526
"id",
2627
"name",
2728
)
2829
search_fields = (
2930
"name",
30-
"track",
3131
)
3232
list_filter = (
3333
"draft",
3434
"is_company",
35-
"track",
36-
"direction",
35+
"trl",
3736
)
3837

3938
fieldsets = (
@@ -46,7 +45,6 @@ class ProjectAdmin(admin.ModelAdmin):
4645
"leader",
4746
"industry",
4847
"region",
49-
"step",
5048
"draft",
5149
"is_company",
5250
)
@@ -56,10 +54,7 @@ class ProjectAdmin(admin.ModelAdmin):
5654
"Для проектов ПД МосПолитеха",
5755
{
5856
"fields": (
59-
"track",
60-
"direction",
6157
"actuality",
62-
"goal",
6358
"problem",
6459
)
6560
},

projects/constants.py

Lines changed: 0 additions & 9 deletions
This file was deleted.

projects/filters.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ class ProjectFilter(filters.FilterSet):
1313
Adds filtering to DRF list retrieve views
1414
1515
Parameters to filter by:
16-
industry (int), step (int), region (str), name__contains (str),
16+
industry (int), region (str), name__contains (str),
1717
description__contains (str), collaborator__user__in (List[int]),
18-
datetime_created__gt (datetime.datetime), step (int), any_vacancies (bool),
18+
datetime_created__gt (datetime.datetime), any_vacancies (bool),
1919
member_count__gt (int), member_count__lt (int), leader (int), partner_program (int),
2020
is_company (bool).
2121
@@ -25,7 +25,6 @@ class ProjectFilter(filters.FilterSet):
2525
?datetime_created__gt=25.10.2022
2626
equals to .filter(datetime_created__gt=datetime.datetime(...))
2727
?collaborator__user__in=1,2 equals to .filter(collaborator__user__in=[1, 2])
28-
?step=1 equals to .filter(step=1)
2928
?any_vacancies=true equals to .filter(any_vacancies=True)
3029
?collaborator__count__gt=1 equals to .filter(collaborator__count__gt=1)
3130
?is_company=0/?is_company=false equals .filter(is_company=False)
@@ -113,7 +112,6 @@ def filter_by_have_expert_rates(self, queryset, name, value):
113112
collaborator__count__lte = filters.NumberFilter(
114113
field_name="collaborator", method="filter_collaborator_count_lte"
115114
)
116-
step = filters.NumberFilter(field_name="step")
117115
partner_program = filters.NumberFilter(
118116
field_name="partner_program", method="filter_by_partner_program"
119117
)
@@ -128,10 +126,8 @@ class Meta:
128126
model = Project
129127
fields = (
130128
"industry",
131-
"step",
132129
"region",
133130
"leader",
134-
"step",
135131
"partner_program",
136132
"is_company",
137133
)

projects/helpers.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from rest_framework.exceptions import ValidationError
88

99
from partner_programs.models import PartnerProgram, PartnerProgramUserProfile
10-
from projects.constants import RECOMMENDATIONS_COUNT
1110
from projects.models import Project, ProjectLink, Achievement
1211
from users.models import CustomUser
1312

@@ -18,7 +17,7 @@ def get_recommended_users(project: Project) -> list[User]:
1817
"""
1918
Searches for users by matching their skills and vacancies required_skills
2019
"""
21-
20+
RECOMMENDATIONS_COUNT = 5
2221
all_needed_skills = set()
2322
for vacancy in project.vacancies.all():
2423
all_needed_skills.update(set(vacancy.get_required_skills()))
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Generated by Django 4.2.11 on 2025-09-02 07:59
2+
3+
import django.core.validators
4+
from django.db import migrations, models
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
("projects", "0027_alter_defaultprojectcover_datetime_created_and_more"),
11+
]
12+
13+
operations = [
14+
migrations.RemoveField(
15+
model_name="project",
16+
name="direction",
17+
),
18+
migrations.RemoveField(
19+
model_name="project",
20+
name="goal",
21+
),
22+
migrations.RemoveField(
23+
model_name="project",
24+
name="step",
25+
),
26+
migrations.RemoveField(
27+
model_name="project",
28+
name="track",
29+
),
30+
migrations.AddField(
31+
model_name="project",
32+
name="implementation_deadline",
33+
field=models.DateField(
34+
blank=True,
35+
help_text="Дата, до которой планируется реализовать проект",
36+
null=True,
37+
verbose_name="Общий срок реализации проекта",
38+
),
39+
),
40+
migrations.AddField(
41+
model_name="project",
42+
name="target_audience",
43+
field=models.CharField(
44+
blank=True,
45+
help_text="Описание целевой аудитории проекта (до 500 симв.)",
46+
max_length=500,
47+
null=True,
48+
verbose_name="Целевая аудитория",
49+
),
50+
),
51+
migrations.AddField(
52+
model_name="project",
53+
name="trl",
54+
field=models.PositiveSmallIntegerField(
55+
blank=True,
56+
help_text="Technology Readiness Level (от 1 до 9)",
57+
null=True,
58+
validators=[
59+
django.core.validators.MinValueValidator(1),
60+
django.core.validators.MaxValueValidator(9),
61+
],
62+
verbose_name="TRL",
63+
),
64+
),
65+
]

projects/models.py

Lines changed: 45 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@
22

33
from django.contrib.auth import get_user_model
44
from django.contrib.contenttypes.fields import GenericRelation
5-
from django.core.validators import MaxLengthValidator
5+
from django.core.validators import (
6+
MaxLengthValidator,
7+
MaxValueValidator,
8+
MinValueValidator,
9+
)
610
from django.db import models
711
from django.db.models import UniqueConstraint
812

913
from core.models import Like, View
1014
from files.models import UserFile
1115
from industries.models import Industry
12-
from projects.constants import VERBOSE_STEPS
1316
from projects.managers import AchievementManager, CollaboratorManager, ProjectManager
1417
from users.models import CustomUser
1518

@@ -60,61 +63,62 @@ class Meta:
6063

6164
class Project(models.Model):
6265
"""
63-
Project model
64-
65-
Attributes:
66-
name: A CharField name of the project.
67-
description: A TextField description of the project.
68-
region: A CharField region of the project.
69-
step: A PositiveSmallIntegerField which indicates status of the project
70-
according to VERBOSE_STEPS.
71-
industry: A ForeignKey referring to the Industry model.
72-
presentation_address: A URLField presentation URL address.
73-
image_address: A URLField image URL address.
74-
leader: A ForeignKey referring to the User model.
75-
draft: A boolean indicating if Project is a draft.
76-
is_company: A boolean indicating if Project is a company.
77-
cover_image_address: A URLField cover image URL address.
78-
cover: A ForeignKey referring to the UserFile model, which is the image cover of the project.
79-
datetime_created: A DateTimeField indicating date of creation.
80-
datetime_updated: A DateTimeField indicating date of update.
66+
Модель проекта.
67+
68+
Атрибуты:
69+
name (CharField): Название проекта.
70+
description (TextField): Подробное описание проекта.
71+
region (CharField): Регион, в котором реализуется проект.
72+
hidden_score (PositiveSmallIntegerField): Скрытый рейтинг проекта,
73+
используется для внутренней сортировки.
74+
actuality (TextField): Актуальность проекта (почему он важен).
75+
target_audience (CharField): Описание целевой аудитории проекта.
76+
implementation_deadline (DateField): Общий срок реализации проекта (дата завершения).
77+
problem (TextField): Проблема, которую решает проект.
78+
trl (PositiveSmallIntegerField): Уровень технологической готовности (Technology Readiness Level) от 1 до 9.
79+
industry (ForeignKey): Ссылка на отрасль (модель Industry).
80+
presentation_address (URLField): Ссылка на презентацию проекта.
81+
image_address (URLField): Ссылка на изображение (аватар проекта).
82+
leader (ForeignKey): Руководитель проекта (пользователь).
83+
draft (BooleanField): Флаг, указывающий, является ли проект черновиком.
84+
is_company (BooleanField): Признак того, что проект представляет компанию.
85+
cover_image_address (URLField): Ссылка на обложку проекта.
86+
cover (ForeignKey): Файл-обложка проекта (устаревшее поле).
87+
subscribers (ManyToManyField): Подписчики проекта.
88+
datetime_created (DateTimeField): Дата создания проекта.
89+
datetime_updated (DateTimeField): Дата последнего изменения проекта.
8190
"""
8291

8392
name = models.CharField(max_length=256, null=True, blank=True)
8493
description = models.TextField(null=True, blank=True)
8594
region = models.CharField(max_length=256, null=True, blank=True)
86-
step = models.PositiveSmallIntegerField(
87-
choices=VERBOSE_STEPS, null=True, blank=True
88-
)
8995
hidden_score = models.PositiveSmallIntegerField(default=100)
90-
91-
track = models.CharField(
92-
max_length=256,
93-
blank=True,
94-
null=True,
95-
verbose_name="Трек",
96-
help_text="Направление/курс, в рамках которого реализуется проект",
97-
)
98-
direction = models.CharField(
99-
max_length=256,
100-
blank=True,
101-
null=True,
102-
verbose_name="Направление",
103-
help_text="Более общее направление деятельности проекта",
104-
)
10596
actuality = models.TextField(
10697
blank=True,
10798
null=True,
10899
validators=[MaxLengthValidator(1000)],
109100
verbose_name="Актуальность",
110101
help_text="Почему проект важен (до 1000 симв.)",
111102
)
112-
goal = models.CharField(
103+
target_audience = models.CharField(
113104
max_length=500,
114105
blank=True,
115106
null=True,
116-
verbose_name="Цель",
117-
help_text="Главная цель проекта (до 500 симв.)",
107+
verbose_name="Целевая аудитория",
108+
help_text="Описание целевой аудитории проекта (до 500 симв.)",
109+
)
110+
trl = models.PositiveSmallIntegerField(
111+
verbose_name="TRL",
112+
help_text="Technology Readiness Level (от 1 до 9)",
113+
validators=[MinValueValidator(1), MaxValueValidator(9)],
114+
null=True,
115+
blank=True,
116+
)
117+
implementation_deadline = models.DateField(
118+
verbose_name="Общий срок реализации проекта",
119+
help_text="Дата, до которой планируется реализовать проект",
120+
null=True,
121+
blank=True,
118122
)
119123
problem = models.TextField(
120124
blank=True,

projects/serializers.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,13 @@ class ProjectDetailSerializer(serializers.ModelSerializer):
122122
links = serializers.SerializerMethodField()
123123
partner_program = serializers.SerializerMethodField()
124124
partner_program_tags = serializers.SerializerMethodField()
125-
track = serializers.CharField(required=False, allow_null=True, allow_blank=True)
126-
direction = serializers.CharField(required=False, allow_null=True, allow_blank=True)
127125
actuality = serializers.CharField(required=False, allow_null=True, allow_blank=True)
128-
goal = serializers.CharField(required=False, allow_null=True, allow_blank=True)
129126
problem = serializers.CharField(required=False, allow_null=True, allow_blank=True)
127+
target_audience = serializers.CharField(
128+
required=False, allow_blank=True, allow_null=True
129+
)
130+
implementation_deadline = serializers.DateField(required=False, allow_null=True)
131+
trl = serializers.IntegerField(required=False, allow_null=True)
130132

131133
def get_partner_program(self, project):
132134
try:
@@ -172,7 +174,6 @@ class Meta:
172174
"achievements",
173175
"links",
174176
"region",
175-
"step",
176177
"industry",
177178
"industry_id",
178179
"presentation_address",
@@ -187,11 +188,11 @@ class Meta:
187188
"views_count",
188189
"cover",
189190
"cover_image_address",
190-
"track",
191-
"direction",
192191
"actuality",
193-
"goal",
194192
"problem",
193+
"target_audience",
194+
"implementation_deadline",
195+
"trl",
195196
"partner_program_tags",
196197
"partner_program",
197198
]

projects/tests.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ def setUp(self):
1919
"name": "Test",
2020
"description": "Test",
2121
"industry": Industry.objects.create(name="Test").id,
22-
"step": 1,
2322
}
2423

2524
def test_project_creation(self):
@@ -42,7 +41,6 @@ def test_project_creation_with_wrong_data(self):
4241
"name": "T" * 257,
4342
"description": "Test",
4443
"industry": Industry.objects.create(name="Test").id,
45-
"step": 1,
4644
},
4745
)
4846
force_authenticate(request, user=user)

projects/urls.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
ProjectDetail,
1313
ProjectList,
1414
ProjectRecommendedUsers,
15-
ProjectSteps,
1615
ProjectSubscribe,
1716
ProjectSubscribers,
1817
ProjectUnsubscribe,
@@ -50,7 +49,6 @@
5049
name="update_program_fields",
5150
),
5251
path("count/", ProjectCountView.as_view()),
53-
path("steps/", ProjectSteps.as_view()),
5452
path("achievements/", AchievementList.as_view()),
5553
path("achievements/<int:pk>/", AchievementDetail.as_view()),
5654
path("<int:id>/responses/", ProjectVacancyResponses.as_view()),

0 commit comments

Comments
 (0)