Refactoring

* splits ema/models.py into subpackage
* splits konova/models.py into subpackage
* splits user/models.py into subpackage
This commit is contained in:
2021-11-15 17:41:52 +01:00
parent 26ae6bc96b
commit 65f02c5111
11 changed files with 252 additions and 160 deletions

10
user/models/__init__.py Normal file
View File

@@ -0,0 +1,10 @@
"""
Author: Michel Peltriaux
Organization: Struktur- und Genehmigungsdirektion Nord, Rhineland-Palatinate, Germany
Contact: michel.peltriaux@sgdnord.rlp.de
Created on: 15.11.21
"""
from .user_action import *
from .konova_user import *
from .notification import *

View File

@@ -0,0 +1,19 @@
"""
Author: Michel Peltriaux
Organization: Struktur- und Genehmigungsdirektion Nord, Rhineland-Palatinate, Germany
Contact: michel.peltriaux@sgdnord.rlp.de
Created on: 15.11.21
"""
from django.contrib.auth.models import User
from django.db import models
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("user.UserNotification", related_name="+")

View File

@@ -0,0 +1,34 @@
"""
Author: Michel Peltriaux
Organization: Struktur- und Genehmigungsdirektion Nord, Rhineland-Palatinate, Germany
Contact: michel.peltriaux@sgdnord.rlp.de
Created on: 15.11.21
"""
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

View File

@@ -1,44 +1,15 @@
"""
Author: Michel Peltriaux
Organization: Struktur- und Genehmigungsdirektion Nord, Rhineland-Palatinate, Germany
Contact: michel.peltriaux@sgdnord.rlp.de
Created on: 15.11.21
"""
import uuid
from django.utils.translation import gettext_lazy as _
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="+")
from django.utils.translation import gettext_lazy as _
class UserAction(models.TextChoices):