Skip to content

Commit 8575aea

Browse files
authored
Merge pull request #450 from PROCOLLAB-github/feature/rework_user_profile
PRO-471: New profile fields
2 parents df34fe9 + eff3578 commit 8575aea

13 files changed

Lines changed: 737 additions & 65 deletions

.flake8

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
[flake8]
22
max-line-length = 120
33

4+
ignore =
5+
VNE002
6+
VNE003
7+
W503
8+
49
exclude =
510
./.cache,
611
./.git,

news/serializers.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
from files.serializers import UserFileSerializer
66
from news.mapping import NewsMapping
77
from news.models import News
8+
from projects.models import Project
9+
from users.models import CustomUser
10+
from feed.mapping import CONTENT_OBJECT_MAPPING, CONTENT_OBJECT_SERIALIZER_MAPPING
811

912

1013
User = get_user_model()

poetry.lock

Lines changed: 12 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

projects/urls.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
ProjectSubscribers,
1818
SwitchLeaderRole,
1919
LeaveProject,
20-
SwitchLeaderRole,
2120
)
2221

2322
app_name = "projects"

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ celery = "^5.4.0"
7070
django-celery-beat = "^2.6.0"
7171
weasyprint = "^62.3"
7272
django-anymail = "^12.0"
73+
phonenumbers = "^8.13.47"
7374

7475

7576
[build-system]

users/admin.py

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
Investor,
2020
UserLink,
2121
UserEducation,
22+
UserWorkExperience,
2223
UserSkillConfirmation,
24+
UserLanguages,
2325
)
2426

2527
from core.admin import SkillToObjectInline
@@ -30,8 +32,22 @@
3032
class UserEducationInline(admin.TabularInline):
3133
model = UserEducation
3234
extra = 1
33-
verbose_name = "Образование"
34-
verbose_name_plural = "Образования"
35+
verbose_name = "Образование пользователя"
36+
verbose_name_plural = "Образование пользователя"
37+
38+
39+
class UserWorkExperienceInline(admin.TabularInline):
40+
model = UserWorkExperience
41+
extra = 1
42+
verbose_name = "Работа пользователя"
43+
verbose_name_plural = "Работа пользователя"
44+
45+
46+
class UserLanguagesInline(admin.TabularInline):
47+
model = UserLanguages
48+
extra = 1
49+
verbose_name = "Знание языка"
50+
verbose_name_plural = "Знание языков"
3551

3652

3753
@admin.register(CustomUser)
@@ -54,6 +70,7 @@ class CustomUserAdmin(admin.ModelAdmin):
5470
"fields": (
5571
"email",
5672
"password",
73+
"phone_number",
5774
)
5875
},
5976
),
@@ -134,6 +151,8 @@ class CustomUserAdmin(admin.ModelAdmin):
134151
inlines = [
135152
SkillToObjectInline,
136153
UserEducationInline,
154+
UserWorkExperienceInline,
155+
UserLanguagesInline,
137156
]
138157

139158
readonly_fields = ("ordering_score",)
@@ -334,6 +353,20 @@ class UserEducationAdmin(admin.ModelAdmin):
334353
search_fields = ("user__first_name", "user__email")
335354

336355

356+
@admin.register(UserWorkExperience)
357+
class UserWorkExperienceAdmin(admin.ModelAdmin):
358+
list_display = ("id", "user", "organization_name", "entry_year")
359+
list_display_links = ("id", "organization_name")
360+
search_fields = ("user__first_name", "user__email")
361+
362+
363+
@admin.register(UserLanguages)
364+
class UserLanguagesAdmin(admin.ModelAdmin):
365+
list_display = ("id", "user", "language", "language_level")
366+
list_display_links = ("id", "user")
367+
search_fields = ("user__first_name", "user__email")
368+
369+
337370
@admin.register(UserSkillConfirmation)
338371
class UserSkillConfirmationAdmin(admin.ModelAdmin):
339372
list_display = ("id", "get_user_and_skill", "confirmed_by", "confirmed_at")

users/constants.py

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,86 @@ class OnboardingStage(Enum):
3535
PROTOCOL = "https"
3636
if settings.DEBUG:
3737
PROTOCOL = "http"
38+
39+
40+
NOT_VALID_NUMBER_MESSAGE: str = (
41+
"Номер телефона должен соответствовать международному стандарту. "
42+
"Пример: +7 XXX XX-XX-XX | +375XXXXXXXXX | +995 (XXX) XX-XX-XX"
43+
)
44+
45+
46+
class UserEducationLevels(Enum):
47+
"""User education level lists to select from."""
48+
49+
SCHOOL = "Среднее общее образование"
50+
COLLEGE = "Среднее профессиональное образование"
51+
HIGHER_BACALAVR = "Высшее образование – бакалавриат, специалитет"
52+
HIGHER_MAGISTRACY = "Высшее образование – магистратура"
53+
HIGHER_POSTGRADUATE = "Высшее образование – аспирантура"
54+
55+
@classmethod
56+
def choices(cls):
57+
"""Return a list of tuples (value, display_name) for choices."""
58+
return [(item.value, item.value) for item in cls]
59+
60+
61+
class UserEducationStatuses(Enum):
62+
"""User education status lists to select from."""
63+
64+
APPRENTICE = "Ученик"
65+
STUDENT = "Студент"
66+
GRADUATE = "Выпускник"
67+
68+
@classmethod
69+
def choices(cls):
70+
"""Return a list of tuples (value, display_name) for choices."""
71+
return [(item.value, item.value) for item in cls]
72+
73+
74+
USER_EXPERIENCE_YEAR_VALIDATION_MESSAGE: str = "Год начала не может быть больше года завершения"
75+
76+
# Working with user languages:
77+
USER_MAX_LANGUAGES_COUNT: int = 4
78+
COUNT_LANGUAGES_VALIDATION_MESSAGE: str = "Пользователь не может указать более 4 языков."
79+
UNIQUE_LANGUAGES_VALIDATION_MESSAGE: str = "Нельзя добавлять дубликаты языков"
80+
81+
82+
class UserLanguagesEnum(Enum):
83+
"""User languages lists to select from."""
84+
85+
ENGLISH = "Английский"
86+
SPANISCH = "Испанский"
87+
ITALIAN = "Итальянский"
88+
GERMAN = "Немецкий"
89+
JAPANESE = "Японский"
90+
CHINESE = "Китайский"
91+
ARABIC = "Арабский"
92+
SWEDISH = "Шведский"
93+
POLISH = "Польский"
94+
CZECH = "Чешский"
95+
RUSSIAN = "Русский"
96+
FRENCH = "Французский"
97+
98+
@classmethod
99+
def choices(cls):
100+
"""Return a list of tuples (value, display_name) for choices."""
101+
return [(item.value, item.value) for item in cls]
102+
103+
104+
class UserLanguagesLevels(Enum):
105+
"""
106+
User languages levels lists to select from.
107+
(Level value in Cyrillic)
108+
"""
109+
110+
А1 = "А1"
111+
А2 = "А2"
112+
B1 = "B1"
113+
B2 = "B2"
114+
С1 = "С1"
115+
С2 = "С2"
116+
117+
@classmethod
118+
def choices(cls):
119+
"""Return a list of tuples (value, display_name) for choices."""
120+
return [(item.value, item.value) for item in cls]

users/migrations/0049_alter_customuser_key_skills_and_more.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ class Migration(migrations.Migration):
7575
models.PositiveSmallIntegerField(
7676
blank=True,
7777
null=True,
78-
validators=[users.validators.user_entry_year_education_validator],
78+
# Unable to perform new migrations due to missing validator:
79+
# validators=[users.validators.user_entry_year_education_validator],
7980
verbose_name="Год поступления",
8081
),
8182
),

0 commit comments

Comments
 (0)