* splits ema/models.py into subpackage * splits konova/models.py into subpackage * splits user/models.py into subpackage
50 lines
1.2 KiB
Python
50 lines
1.2 KiB
Python
"""
|
|
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 django.utils.translation import gettext_lazy as _
|
|
|
|
from konova.models import BaseResource
|
|
|
|
|
|
class DeadlineType(models.TextChoices):
|
|
"""
|
|
Django 3.x way of handling enums for models
|
|
"""
|
|
FINISHED = "finished", _("Finished")
|
|
MAINTAIN = "maintain", _("Maintain")
|
|
CONTROL = "control", _("Control")
|
|
OTHER = "other", _("Other")
|
|
|
|
|
|
class Deadline(BaseResource):
|
|
"""
|
|
Defines a deadline, which can be used to define dates with a semantic meaning
|
|
"""
|
|
|
|
type = models.CharField(max_length=255, null=True, blank=True, choices=DeadlineType.choices)
|
|
date = models.DateField(null=True, blank=True)
|
|
comment = models.TextField(null=True, blank=True)
|
|
|
|
def __str__(self):
|
|
return self.type
|
|
|
|
@property
|
|
def type_humanized(self):
|
|
""" Returns humanized version of enum
|
|
|
|
Used for template rendering
|
|
|
|
Returns:
|
|
|
|
"""
|
|
choices = DeadlineType.choices
|
|
for choice in choices:
|
|
if choice[0] == self.type:
|
|
return choice[1]
|
|
return None
|