hubl/src/server/models.py

84 lines
2.6 KiB
Python
Raw Normal View History

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
class Member(models.Model):
2018-07-08 18:17:34 +00:00
avatar = models.URLField(blank=True)
available = models.NullBooleanField(blank=True)
bio = models.CharField(max_length=255, blank=True, null=True)
cell = models.ForeignKey("Cell", on_delete=models.DO_NOTHING, blank=True, null=True)
jabberID = models.CharField(max_length=255, blank=True, null=True)
jabberRoom = models.NullBooleanField(blank=True)
2018-06-21 08:57:25 +00:00
user = models.OneToOneField(User, on_delete=models.CASCADE)
number = models.CharField(max_length=255, blank=True, null=True)
2018-05-16 06:08:38 +00:00
projects = models.ManyToManyField("Project", blank=True)
2018-07-08 18:17:34 +00:00
pseudo = models.CharField(max_length=255, blank=True, null=True)
roles = models.ManyToManyField("Role", blank=True)
skills = models.ManyToManyField("Skill", blank=True)
website = models.URLField(blank=True)
def __str__(self):
2018-07-08 18:17:34 +00:00
return 'Profil de {} '.format(self.user.get_full_name())
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()
class Skill(models.Model):
name = models.CharField(max_length=255, default='')
def __str__(self):
return self.name
2018-07-08 18:17:34 +00:00
class Role(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='')
2018-07-08 18:17:34 +00:00
number = models.PositiveIntegerField(default='0', blank=True)
client = models.ForeignKey("Client", on_delete=models.DO_NOTHING)
2018-05-16 06:08:38 +00:00
team = models.ManyToManyField("Member", blank=True)
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()
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-25 23:35:44 +00:00
def __str__(self):
return self.name
2018-06-21 08:57:25 +00:00