Created|Deleted refactoring
* refactors base attributes created and deleted into UserActionLogEntry foreign keys * refactors all related queries and process logic * fixes binding_on into binding_date in intervention/detail/view.html * adds basic __str__ for some models *
This commit is contained in:
+26
-4
@@ -12,6 +12,7 @@ from django.utils import timezone
|
||||
from django.utils.timezone import now
|
||||
|
||||
from intervention.settings import INTERVENTION_IDENTIFIER_LENGTH, INTERVENTION_IDENTIFIER_TEMPLATE
|
||||
from konova.enums import UserActionLogEntryEnum
|
||||
from konova.models import BaseObject, Geometry, UuidModel
|
||||
from konova.utils import generators
|
||||
from konova.utils.generators import generate_random_string
|
||||
@@ -30,6 +31,13 @@ class ResponsibilityData(UuidModel):
|
||||
conservation_file_number = models.CharField(max_length=1000, blank=True, null=True)
|
||||
handler = models.CharField(max_length=500, null=True, blank=True, help_text="Refers to 'Eingriffsverursacher'")
|
||||
|
||||
def __str__(self):
|
||||
return "ZB: {} | ETS: {} | Handler: {}".format(
|
||||
self.registration_office,
|
||||
self.conservation_office,
|
||||
self.handler
|
||||
)
|
||||
|
||||
|
||||
class LegalData(UuidModel):
|
||||
"""
|
||||
@@ -44,6 +52,13 @@ class LegalData(UuidModel):
|
||||
process_type = models.CharField(max_length=500, null=True, blank=True)
|
||||
law = models.CharField(max_length=500, null=True, blank=True)
|
||||
|
||||
def __str__(self):
|
||||
return "{} | {} | {}".format(
|
||||
self.process_type,
|
||||
self.law,
|
||||
self.id
|
||||
)
|
||||
|
||||
|
||||
class Intervention(BaseObject):
|
||||
"""
|
||||
@@ -121,13 +136,20 @@ class Intervention(BaseObject):
|
||||
with transaction.atomic():
|
||||
# "Delete" related compensations as well
|
||||
coms = self.compensations.all()
|
||||
action = UserActionLogEntry.objects.create(
|
||||
user=_user,
|
||||
timestamp=_now,
|
||||
action=UserActionLogEntryEnum.DELETED.value
|
||||
)
|
||||
for com in coms:
|
||||
com.deleted_on = _now
|
||||
com.deleted_by = _user
|
||||
com.deleted = action
|
||||
#com.deleted_on = _now
|
||||
#com.deleted_by = _user
|
||||
com.save()
|
||||
|
||||
self.deleted_on = _now
|
||||
self.deleted_by = _user
|
||||
self.deleted = action
|
||||
#self.deleted_on = _now
|
||||
#self.deleted_by = _user
|
||||
self.save()
|
||||
|
||||
@staticmethod
|
||||
|
||||
Reference in New Issue
Block a user