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:
mipel
2021-08-02 11:52:20 +02:00
parent 6bc8ada286
commit 0797a6b99f
17 changed files with 138 additions and 60 deletions
+7 -1
View File
@@ -15,10 +15,12 @@ from django.urls import reverse
from django.utils.translation import gettext_lazy as _
from intervention.models import Intervention
from konova.enums import UserActionLogEntryEnum
from konova.forms import BaseForm, BaseModalForm
from konova.models import Document
from konova.settings import DEFAULT_LAT, DEFAULT_LON, DEFAULT_ZOOM
from organisation.models import Organisation
from user.models import UserActionLogEntry
class NewInterventionForm(BaseForm):
@@ -115,6 +117,10 @@ class NewInterventionForm(BaseForm):
geometry = self.cleaned_data.get("geometry", Polygon())
documents = self.cleaned_data.get("documents", []) or []
action = UserActionLogEntry.objects.create(
user=user,
action=UserActionLogEntryEnum.CREATED.value,
)
intervention = Intervention(
identifier=identifier,
title=title,
@@ -124,7 +130,7 @@ class NewInterventionForm(BaseForm):
data_provider=data_provider,
data_provider_detail=data_provider_detail,
geometry=geometry,
created_by=user,
created=action,
)
intervention.save()
for doc in documents: