2018-04-05 12:09:42 +00:00
|
|
|
from django.db import models
|
2018-06-21 08:57:25 +00:00
|
|
|
from django.contrib.auth.models import User
|
|
|
|
from django.db.models.signals import post_save
|
|
|
|
from django.dispatch import receiver
|
2018-04-05 12:09:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Member(models.Model):
|
2018-06-21 08:57:25 +00:00
|
|
|
user = models.OneToOneField(User, on_delete=models.CASCADE)
|
2018-04-05 12:09:42 +00:00
|
|
|
avatar = models.URLField()
|
2018-06-21 08:57:25 +00:00
|
|
|
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)
|
2018-05-16 06:08:38 +00:00
|
|
|
skills = models.ManyToManyField("Skill", blank=True)
|
|
|
|
projects = models.ManyToManyField("Project", blank=True)
|
2018-04-05 12:09:42 +00:00
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.firstname +' '+ self.lastname
|
|
|
|
|
2018-06-21 08:57:25 +00:00
|
|
|
@receiver(post_save, sender=User)
|
|
|
|
def create_user_profile(sender, instance, created, **kwargs):
|
|
|
|
if created:
|
|
|
|
Member.objects.create(user=instance)
|
|
|
|
else:
|
|
|
|
instance.member.save()
|
|
|
|
|
2018-04-05 12:09:42 +00:00
|
|
|
|
|
|
|
class Skill(models.Model):
|
|
|
|
name = models.CharField(max_length=255, default='')
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.name
|
|
|
|
|
|
|
|
|
|
|
|
class Project(models.Model):
|
|
|
|
name = models.CharField(max_length=255, default='')
|
|
|
|
number = models.PositiveIntegerField(default='0')
|
2018-06-21 08:57:25 +00:00
|
|
|
client = models.OneToOneField("Client", on_delete=models.DO_NOTHING)
|
2018-05-16 06:08:38 +00:00
|
|
|
team = models.ManyToManyField("Member", blank=True)
|
2018-04-05 12:09:42 +00:00
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.name
|
|
|
|
|
|
|
|
|
|
|
|
class Client(models.Model):
|
|
|
|
name = models.CharField(max_length=255, default='')
|
|
|
|
address = models.CharField(max_length=255, default='')
|
2018-04-23 13:07:58 +00:00
|
|
|
logo = models.URLField()
|
2018-04-05 12:09:42 +00:00
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.name
|
|
|
|
|
|
|
|
|
|
|
|
class Cell(models.Model):
|
|
|
|
name = models.CharField(max_length=255, default='')
|
|
|
|
city = models.CharField(max_length=255, default='')
|
|
|
|
country = models.CharField(max_length=255, default='')
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.name
|
|
|
|
|
|
|
|
|
2018-05-16 03:09:59 +00:00
|
|
|
class Channel(models.Model):
|
2018-04-25 23:35:44 +00:00
|
|
|
name = models.CharField(max_length=255, default='')
|
|
|
|
description = models.CharField(max_length=255, default='')
|
2018-05-16 06:08:38 +00:00
|
|
|
members = models.ManyToManyField("Member", blank=True)
|
2018-06-21 08:57:25 +00:00
|
|
|
owner = models.ForeignKey("Member", related_name="owned_chatrooms", on_delete=models.DO_NOTHING)
|
2018-04-05 12:09:42 +00:00
|
|
|
|
2018-04-25 23:35:44 +00:00
|
|
|
def __str__(self):
|
|
|
|
return self.name
|
2018-06-21 08:57:25 +00:00
|
|
|
|