You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
751 B
34 lines
751 B
from django.db.models import Model, CharField, ManyToManyField |
|
from django.contrib.auth.models import AbstractUser |
|
|
|
|
|
class User(AbstractUser): |
|
"""User |
|
|
|
I don't know why I make it people.User though, but I do it anyway, |
|
easier access maybe? |
|
""" |
|
|
|
def __str__(self): |
|
return self.username |
|
|
|
@property |
|
def organization(self): |
|
try: |
|
return self.organization_set.all()[0] |
|
except: |
|
return None |
|
|
|
|
|
class Organization(Model): |
|
"""Organization to hold all models together |
|
""" |
|
name = CharField('Organization Name', max_length=200) |
|
users = ManyToManyField('User') |
|
|
|
|
|
class Meta: |
|
verbose_name_plural = "Organizations" |
|
|
|
def __str__(self): |
|
return self.name
|
|
|