Intervention model refactoring

* adds UserActionLogEntry model to user/models.py
  * wraps user and timestamp info
  * can be extended for more information in the future
* refactors all filtering and accessing on values
This commit is contained in:
mipel
2021-07-29 15:49:19 +02:00
parent 98e0971c4b
commit 4e9f0f3c88
9 changed files with 82 additions and 24 deletions
+19 -10
View File
@@ -15,6 +15,7 @@ from intervention.settings import INTERVENTION_IDENTIFIER_LENGTH, INTERVENTION_I
from konova.models import BaseObject, Geometry
from konova.utils.generators import generate_random_string
from organisation.models import Organisation
from user.models import UserActionLogEntry
class Intervention(BaseObject):
@@ -32,27 +33,35 @@ class Intervention(BaseObject):
geometry = models.ForeignKey(Geometry, null=True, blank=True, on_delete=models.SET_NULL)
documents = models.ManyToManyField("konova.Document", blank=True)
# Checks
checked_on = models.DateTimeField(default=None, null=True, blank=True)
checked_by = models.ForeignKey(User, null=True, blank=True, on_delete=models.SET_NULL, related_name='+')
# Refers to "zugelassen am"
registration_date = models.DateField(null=True, blank=True)
# Refers to "Bestandskraft am"
binding_on = models.DateField(null=True, blank=True)
# Checks - Refers to "Genehmigen" but optional
checked = models.OneToOneField(
UserActionLogEntry,
on_delete=models.SET_NULL,
null=True,
blank=True,
help_text="Holds data on user and timestamp of this action",
related_name="+"
)
# Refers to "verzeichnen"
recorded_on = models.DateTimeField(default=None, null=True, blank=True)
recorded_by = models.ForeignKey(User, null=True, blank=True, on_delete=models.SET_NULL, related_name='+')
recorded = models.OneToOneField(
UserActionLogEntry,
on_delete=models.SET_NULL,
null=True,
blank=True,
help_text="Holds data on user and timestamp of this action",
related_name="+"
)
# Holds which intervention is simply a newer version of this dataset
next_version = models.ForeignKey("Intervention", null=True, blank=True, on_delete=models.DO_NOTHING)
# Compensation or payments, one-directional
#payments = models.ManyToManyField(Payment, related_name="+", blank=True)
#compensations = models.ManyToManyField(Compensation, related_name="+", blank=True)
# Users having access on this object
users = models.ManyToManyField(User)