-
Notifications
You must be signed in to change notification settings - Fork 1
add type-hints vacancy #312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from 15 commits
6fcb003
4abd77d
fbb1352
99c5eed
2561e72
df51d69
78f4c00
da12c13
8c93cc8
e3a7321
2c64569
77a416c
7f69ddf
f706ae3
be8f3ef
284ce77
7250222
974940d
a5a88aa
c9294e5
6b604d7
575e2f2
3d8f285
8fa264c
fa94f00
7779dbf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,7 @@ | |
| from vacancy.models import Vacancy | ||
|
|
||
|
|
||
| def project_id_filter(queryset, name, value): | ||
| def project_id_filter(queryset, name, value) -> queryset: | ||
| return queryset.filter( | ||
| **{ | ||
| "project_id": value[0], | ||
|
|
@@ -27,7 +27,7 @@ class VacancyFilter(filters.FilterSet): | |
|
|
||
| def __init__(self, *args, **kwargs): | ||
| """if is_active filter is not passed, default to True""" | ||
| super().__init__(*args, **kwargs) | ||
| super().init(*args, **kwargs) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. почему так? |
||
| if self.data.get("is_active") is None: | ||
| self.data = dict(self.data) | ||
| self.data["is_active"] = True | ||
|
|
@@ -37,4 +37,4 @@ def __init__(self, *args, **kwargs): | |
|
|
||
| class Meta: | ||
| model = Vacancy | ||
| fields = ("project_id", "is_active") | ||
| fields = ("project_id", "is_active") | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,7 +12,7 @@ class RequiredSkillsSerializerMixin(serializers.Serializer): | |
| required_skills = CustomListField(child=serializers.CharField()) | ||
|
|
||
|
|
||
| class ProjectForVacancySerializer(serializers.ModelSerializer): | ||
| class ProjectForVacancySerializer(serializers.ModelSerializer[Project]): | ||
| class Meta: | ||
| model = Project | ||
| fields = [ | ||
|
|
@@ -23,7 +23,7 @@ class Meta: | |
| ] | ||
|
|
||
|
|
||
| class VacancyDetailSerializer(serializers.ModelSerializer, RequiredSkillsSerializerMixin): | ||
| class VacancyDetailSerializer(serializers.ModelSerializer, RequiredSkillsSerializerMixin[Vacancy]): | ||
| project = ProjectForVacancySerializer(many=False, read_only=True) | ||
|
|
||
| class Meta: | ||
|
|
@@ -41,7 +41,7 @@ class Meta: | |
| read_only_fields = ["project"] | ||
|
|
||
|
|
||
| class VacancyListSerializer(serializers.ModelSerializer, RequiredSkillsSerializerMixin): | ||
| class VacancyListSerializer(serializers.ModelSerializer, RequiredSkillsSerializerMixin[Vacancy]): | ||
| class Meta: | ||
| model = Vacancy | ||
| fields = [ | ||
|
|
@@ -57,7 +57,7 @@ class Meta: | |
|
|
||
|
|
||
| class ProjectVacancyListSerializer( | ||
| serializers.ModelSerializer, RequiredSkillsSerializerMixin | ||
| serializers.ModelSerializer, RequiredSkillsSerializerMixin[Project] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. неправильно |
||
| ): | ||
| class Meta: | ||
| model = Vacancy | ||
|
|
@@ -72,7 +72,7 @@ class Meta: | |
|
|
||
|
|
||
| class ProjectVacancyCreateListSerializer( | ||
| serializers.ModelSerializer, RequiredSkillsSerializerMixin | ||
| serializers.ModelSerializer, RequiredSkillsSerializerMixin[Project] | ||
| ): | ||
| class Meta: | ||
| model = Vacancy | ||
|
|
@@ -85,8 +85,18 @@ class Meta: | |
| "is_active", | ||
| ] | ||
|
|
||
| def create(self, validated_data): | ||
| if validated_data["project"].draft: | ||
| validated_data["is_active"] = False | ||
| else: | ||
| validated_data["is_active"] = True | ||
|
|
||
| instance = super().create(validated_data) | ||
|
|
||
| return instance | ||
|
|
||
| class VacancyResponseListSerializer(serializers.ModelSerializer): | ||
|
|
||
| class VacancyResponseListSerializer(serializers.ModelSerializer[VacancyResponse]): | ||
| is_approved = serializers.BooleanField(read_only=True) | ||
| user = UserDetailSerializer(read_only=True) | ||
| user_id = serializers.IntegerField(write_only=True) | ||
|
|
@@ -127,23 +137,7 @@ def create(self, validated_data): | |
| return vacancy_response | ||
|
|
||
|
|
||
| class VacancyResponseDetailSerializer(serializers.ModelSerializer): | ||
| class VacancyResponseDetailSerializer(serializers.ModelSerializer[VacancyResponse]): | ||
| user = UserDetailSerializer(many=False, read_only=True) | ||
| vacancy = VacancyListSerializer(many=False, read_only=True) | ||
| is_approved = serializers.BooleanField(read_only=True) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. почему удалил кусок кода? |
||
|
|
||
| class Meta: | ||
| model = VacancyResponse | ||
| fields = [ | ||
| "id", | ||
| "user", | ||
| "vacancy", | ||
| "why_me", | ||
| "is_approved", | ||
| "datetime_created", | ||
| "datetime_updated", | ||
| ] | ||
|
|
||
|
|
||
| class VacancyResponseAcceptSerializer(VacancyResponseDetailSerializer): | ||
| is_approved = serializers.BooleanField(required=True, read_only=False) | ||
| is_approve | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. что это вообще.. |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
оно точно работает?
кажется тут должен быт QuerySet[Project] или что то такое