-
Notifications
You must be signed in to change notification settings - Fork 6
/
models.py
44 lines (35 loc) · 1.4 KB
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from django.db import models
from django.contrib.auth.models import AbstractUser
from .managers import CustomUserManager
from .enums import CATEGORY, ROLES
from core.models import AuditableModel
from django.contrib.auth.models import PermissionsMixin
class CustomUser(AbstractUser, PermissionsMixin):
username = None # Here
email = models.EmailField('email address', unique=True) # Here
firstname = models.CharField(max_length=256) # Here
lastname = models.CharField(max_length=256) # Here
role = models.CharField(max_length=50, choices=ROLES)
USERNAME_FIELD = 'email'
REQUIRED_FIELDS = []
category = models.CharField(
default='unknown', max_length=20, choices=CATEGORY)
objects = CustomUserManager() # Here
# skills = models.CharField()
class Meta:
verbose_name = "user"
verbose_name_plural = "users"
ordering = ('-id',)
def __str__(self):
return f'{self.firstname} {self.lastname}'
class ChurchGroup(AuditableModel):
name = models.CharField(max_length=256)
purpose = models.CharField(max_length=256) # Here
leader = models.ForeignKey(
CustomUser, on_delete=models.SET_NULL, null=True, related_name='leader')
members = models.ManyToManyField(
CustomUser, related_name="group_list", blank=True)
class Meta:
ordering = ('-created_at',)
def __str__(self):
return f'{self.name}'