Intervention check
* adds functionality for check button * adds highlighting of important data on detail view for intervention * adds deleting logic to BaseObject model and BaseResource model * adds RunCheckForm * adds check_validity() method to Intervention class * fixes wrong success msg for adding documents * adds/updates translations
This commit is contained in:
@@ -313,7 +313,7 @@ class NewDocumentForm(BaseModalForm):
|
||||
created=action,
|
||||
title=self.cleaned_data["title"],
|
||||
comment=self.cleaned_data["comment"],
|
||||
document=self.cleaned_data["file"],
|
||||
file=self.cleaned_data["file"],
|
||||
date_of_creation=self.cleaned_data["creation_date"],
|
||||
)
|
||||
self.instance.documents.add(doc)
|
||||
|
||||
@@ -10,9 +10,9 @@ import uuid
|
||||
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.contrib.gis.db.models import MultiPolygonField
|
||||
from django.db import models
|
||||
from django.db import models, transaction
|
||||
|
||||
from user.models import UserActionLogEntry
|
||||
from user.models import UserActionLogEntry, UserAction
|
||||
|
||||
|
||||
class UuidModel(models.Model):
|
||||
@@ -38,6 +38,11 @@ class BaseResource(UuidModel):
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
def delete(self, using=None, keep_parents=False):
|
||||
if self.created:
|
||||
self.created.delete()
|
||||
super().delete()
|
||||
|
||||
|
||||
class BaseObject(BaseResource):
|
||||
"""
|
||||
@@ -53,6 +58,31 @@ class BaseObject(BaseResource):
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
def delete(self, *args, **kwargs):
|
||||
""" Custom delete functionality
|
||||
|
||||
Does not delete from database but sets a timestamp for being deleted on and which user deleted the object
|
||||
|
||||
Args:
|
||||
*args ():
|
||||
**kwargs ():
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
if self.deleted:
|
||||
# Nothing to do here
|
||||
return
|
||||
|
||||
_user = kwargs.get("user", None)
|
||||
with transaction.atomic():
|
||||
action = UserActionLogEntry.objects.create(
|
||||
user=_user,
|
||||
action=UserAction.DELETED
|
||||
)
|
||||
self.deleted = action
|
||||
self.save()
|
||||
|
||||
|
||||
class DeadlineType(models.TextChoices):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user