server : updated models
This commit is contained in:
parent
a800de7315
commit
63084c571d
@ -1,19 +1,30 @@
|
||||
from django.db import models
|
||||
from django.contrib.auth.models import User
|
||||
from django.db.models.signals import post_save
|
||||
from django.dispatch import receiver
|
||||
|
||||
|
||||
class Member(models.Model):
|
||||
user = models.OneToOneField(User, on_delete=models.CASCADE)
|
||||
avatar = models.URLField()
|
||||
firstname = models.CharField(max_length=255, default='')
|
||||
lastname = models.CharField(max_length=255, default='')
|
||||
email = models.CharField(max_length=255, default='')
|
||||
number = models.CharField(max_length=255, default='')
|
||||
cell = models.ForeignKey("Cell")
|
||||
firstname = models.CharField(max_length=255, blank=True, null=True)
|
||||
lastname = models.CharField(max_length=255, blank=True, null=True)
|
||||
email = models.CharField(max_length=255, blank=True, null=True)
|
||||
number = models.CharField(max_length=255, blank=True, null=True)
|
||||
cell = models.ForeignKey("Cell", on_delete=models.DO_NOTHING, blank=True, null=True)
|
||||
skills = models.ManyToManyField("Skill", blank=True)
|
||||
projects = models.ManyToManyField("Project", blank=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.firstname +' '+ self.lastname
|
||||
|
||||
@receiver(post_save, sender=User)
|
||||
def create_user_profile(sender, instance, created, **kwargs):
|
||||
if created:
|
||||
Member.objects.create(user=instance)
|
||||
else:
|
||||
instance.member.save()
|
||||
|
||||
|
||||
class Skill(models.Model):
|
||||
name = models.CharField(max_length=255, default='')
|
||||
@ -25,7 +36,7 @@ class Skill(models.Model):
|
||||
class Project(models.Model):
|
||||
name = models.CharField(max_length=255, default='')
|
||||
number = models.PositiveIntegerField(default='0')
|
||||
client = models.OneToOneField("Client")
|
||||
client = models.OneToOneField("Client", on_delete=models.DO_NOTHING)
|
||||
team = models.ManyToManyField("Member", blank=True)
|
||||
|
||||
def __str__(self):
|
||||
@ -54,7 +65,8 @@ class Channel(models.Model):
|
||||
name = models.CharField(max_length=255, default='')
|
||||
description = models.CharField(max_length=255, default='')
|
||||
members = models.ManyToManyField("Member", blank=True)
|
||||
owner = models.ForeignKey("Member", related_name="owned_chatrooms")
|
||||
owner = models.ForeignKey("Member", related_name="owned_chatrooms", on_delete=models.DO_NOTHING)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user