33from django .contrib .auth import get_user_model
44from django .db import models
55from django .db .models import UniqueConstraint
6+ from django .db .models .signals import post_save
7+ from django .dispatch import receiver
68
79from industries .models import Industry
810from projects .helpers import VERBOSE_STEPS
@@ -19,7 +21,6 @@ class Project(models.Model):
1921 Attributes:
2022 name: A CharField name of the project.
2123 description: A TextField description of the project.
22- short_description: A TextField short description of the project.
2324 region: A CharField region of the project.
2425 step: A PositiveSmallIntegerField which indicates status of the project
2526 according to VERBOSE_STEPS.
@@ -34,7 +35,6 @@ class Project(models.Model):
3435
3536 name = models .CharField (max_length = 256 , null = True , blank = True )
3637 description = models .TextField (null = True , blank = True )
37- # short_description = models.TextField(null=True, blank=True)
3838 region = models .CharField (max_length = 256 , null = True , blank = True )
3939 step = models .PositiveSmallIntegerField (choices = VERBOSE_STEPS , null = True , blank = True )
4040
@@ -153,3 +153,12 @@ class Meta:
153153 name = "unique_collaborator" ,
154154 )
155155 ]
156+
157+
158+ @receiver (post_save , sender = Project )
159+ def create_project (sender , instance , created , ** kwargs ):
160+ """Creates collaborator for the project leader on project creation"""
161+ if created :
162+ Collaborator .objects .create (
163+ user = instance .leader , project = instance , role = "Основатель"
164+ )
0 commit comments