44from django .dispatch import receiver
55
66from industries .models import Industry
7-
87from users .managers import CustomUserManager
98
109
@@ -14,26 +13,27 @@ def get_default_user_type():
1413
1514class CustomUser (AbstractUser ):
1615 """
17- User model
16+ CustomUser model
17+
18+ This model is used to store the user common information.
1819
1920 Attributes:
2021 email: CharField instance of user's email.
2122 first_name: CharField instance of the user first name.
2223 last_name: CharField instance of the user last name.
23- patronymic: CharField instance of the user patronymic.
2424 password: CharField instance of the user password.
2525 is_active: Boolean indicating if user confirmed email.
26- birthday: DateField instance of the user's birthday.
26+ user_type: PositiveSmallIntegerField indicating the user's type according to VERBOSE_USER_TYPES.
27+ patronymic: CharField instance of the user patronymic.
2728 avatar: URLField instance of the user's avatar url.
28- key_skills: CharField instance of user skills containing keys.
29- useful_to_project: CharField instance of the something useful... TODO
29+ birthday: DateField instance of the user's birthday.
3030 about_me: TextField instance contains information about the user.
3131 status: CharField instance notifies about the user's status.
32- speciality: CharField instance the user's specialty.
33- city: CharField instance the user's name city.
3432 region: CharField instance the user's name region.
33+ city: CharField instance the user's name city.
3534 organization: CharField instance the user's place of study or work.
36- tags: CharField instance tags. TODO
35+ datetime_updated: A DateTimeField indicating date of update.
36+ datetime_created: A DateTimeField indicating date of creation.
3737 """
3838
3939 ADMIN = 0
@@ -56,14 +56,12 @@ class CustomUser(AbstractUser):
5656 last_name = models .CharField (max_length = 255 , blank = False )
5757 password = models .CharField (max_length = 255 , blank = False )
5858 is_active = models .BooleanField (default = False , editable = False )
59- datetime_updated = models .DateTimeField (auto_now = True )
60-
6159 user_type = models .PositiveSmallIntegerField (
6260 choices = VERBOSE_USER_TYPES ,
6361 default = get_default_user_type ,
6462 )
6563
66- patronymic = models .CharField (max_length = 255 , blank = True ) # Отчество
64+ patronymic = models .CharField (max_length = 255 , blank = True )
6765 avatar = models .URLField (null = True , blank = True )
6866 birthday = models .DateField (null = True )
6967 about_me = models .TextField (blank = True )
@@ -72,6 +70,9 @@ class CustomUser(AbstractUser):
7270 city = models .CharField (max_length = 255 , blank = True )
7371 organization = models .CharField (max_length = 255 , blank = True )
7472
73+ datetime_updated = models .DateTimeField (null = False , auto_now = True )
74+ datetime_created = models .DateTimeField (null = False , auto_now_add = True )
75+
7576 USERNAME_FIELD = "email"
7677 REQUIRED_FIELDS = []
7778
@@ -87,6 +88,17 @@ def __str__(self):
8788
8889
8990class AbstractUserWithRole (models .Model ):
91+ """
92+ AbstractUserWithRole abstract model
93+
94+ This model adds additional role field to the user model.
95+
96+ Attributes:
97+ additional_role: PositiveSmallIntegerField indicating the user's additional role
98+ according to VERBOSE_ROLE_TYPES.
99+
100+ """
101+
90102 MENTOR = 2
91103 EXPERT = 3
92104 INVESTOR = 4
@@ -107,13 +119,28 @@ class Meta:
107119
108120
109121class Member (models .Model ):
122+ """
123+ Member model
124+
125+ Represents the CustomUser with the MEMBER user type.
126+
127+ Attributes:
128+ user: ForeignKey instance of the CustomUser model.
129+ key_skills: CharField instance indicating member key skills.
130+ useful_to_project: TextField instance indicates actions useful
131+ for the development and maintenance of the project.
132+ preferred_industries: ManyToManyField indicating user industries preferred for work.
133+ """
134+
110135 user = models .OneToOneField (
111136 CustomUser , on_delete = models .CASCADE , related_name = "member"
112137 )
113138
114- key_skills = models .CharField (max_length = 255 , blank = True ) # TODO
139+ key_skills = models .CharField (max_length = 512 , blank = True )
115140 useful_to_project = models .TextField (blank = True )
116- speciality = models .CharField (max_length = 255 , blank = True )
141+ preferred_industries = models .ManyToManyField (
142+ Industry , blank = True , related_name = "members"
143+ )
117144
118145 def __str__ (self ):
119146 return f"Member<{ self .id } > - { self .user .first_name } { self .user .last_name } "
@@ -123,16 +150,19 @@ class Mentor(AbstractUserWithRole):
123150 """
124151 Mentor model
125152
153+ Represents the CustomUser with the MENTOR user type.
154+
126155 Attributes:
127- job: CharField instance current user job.
128- useful_to_project: CharField instance some text.
156+ user: ForeignKey instance of the CustomUser model.
157+ useful_to_project: TextField instance indicates actions useful
158+ for the development and maintenance of the project.
129159 """
130160
131161 user = models .OneToOneField (
132162 CustomUser , on_delete = models .CASCADE , related_name = "mentor"
133163 )
134-
135- job = models .CharField (max_length = 255 , blank = True )
164+ # CustomUser already has a field called "organization"
165+ # job = models.CharField(max_length=255, blank=True)
136166 useful_to_project = models .TextField (blank = True )
137167
138168 def __str__ (self ):
@@ -143,9 +173,12 @@ class Expert(AbstractUserWithRole):
143173 """
144174 Expert model
145175
176+ Represents the CustomUser with the EXPERT user type.
177+
146178 Attributes:
147- preferred_industries: CharField instance TODO
148- useful_to_project: CharField instance TODO
179+ preferred_industries: ManyToManyField indicating user industries preferred for work.
180+ useful_to_project: TextField instance indicates actions useful
181+ for the development and maintenance of the project.
149182 """
150183
151184 user = models .OneToOneField (
@@ -167,8 +200,10 @@ class Investor(AbstractUserWithRole):
167200 """
168201 Investor model
169202
203+ Represents the CustomUser with the INVESTOR user type.
204+
170205 Attributes:
171- preferred_industries: CharField instance TODO
206+ preferred_industries: ManyToManyField indicating user industries preferred for work.
172207 interaction_process_description: CharField describes the interaction process.
173208
174209 """
0 commit comments