You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
konova/user/models.py

39 lines
1.0 KiB
Python

from django.contrib.auth.models import User
from django.db import models
from user.enums import UserNotificationEnum
class UserNotification(models.Model):
""" Notifications for users
"""
id = models.CharField(
max_length=500,
null=False,
blank=False,
choices=UserNotificationEnum.as_choices(drop_empty_choice=True),
primary_key=True,
)
name = models.CharField(
max_length=500,
null=False,
blank=False,
unique=True,
help_text="Human readable name"
)
is_active = models.BooleanField(default=True, help_text="Can be toggle to enable/disable this notification for all users")
def __str__(self):
return self.name
class KonovaUserExtension(models.Model):
""" Extension model for additional ksp features
Extends the default user model for some extras
"""
user = models.OneToOneField(User, on_delete=models.CASCADE)
notifications = models.ManyToManyField(UserNotification, related_name="+")