Fixes and improvements

* moves diff_states message back to table top for direct presentation in compensation/detail/view.html
* removes diff_states rendering in deadline card in compensation/detail/view.html
* fixes before_state adding based on GET parameter
* refactors UserActionlogEntryEnum into a UserAction TextChoice (Django 3.x)
* adds ordering of compensation states depending on surface value
* refactors ServerMessageImportance from enum into TextChoice (Django 3.x)
* adds/updates translations
This commit is contained in:
mipel
2021-08-03 17:22:41 +02:00
parent 816600535a
commit cd5b2e264b
17 changed files with 215 additions and 164 deletions

View File

@@ -38,22 +38,3 @@ class UnitEnum(BaseEnum):
ha = "ha"
st = "St." # pieces
class ServerMessageImportance(BaseEnum):
"""
Defines importance levels for server messages
"""
DEFAULT = "DEFAULT"
INFO = "INFO"
WARNING = "WARNING"
class UserActionLogEntryEnum(BaseEnum):
"""
Defines different possible user actions for UserActionLogEntry
"""
CHECKED = "Checked"
RECORDED = "Recorded"
CREATED = "Created"
DELETED = "Deleted"

View File

@@ -21,10 +21,9 @@ from django.utils import timezone
from django.utils.translation import gettext_lazy as _
from konova.contexts import BaseContext
from konova.enums import UserActionLogEntryEnum
from konova.models import Document
from konova.utils.message_templates import FORM_INVALID
from user.models import UserActionLogEntry
from user.models import UserActionLogEntry, UserAction
class BaseForm(forms.Form):
@@ -117,11 +116,9 @@ class RemoveForm(BaseForm):
action = UserActionLogEntry.objects.create(
user=user,
timestamp=timezone.now(),
action=UserActionLogEntryEnum.DELETED.value
action=UserAction.DELETED
)
self.object_to_remove.deleted = action
#self.object_to_remove.deleted_on = timezone.now()
#self.object_to_remove.deleted_by = user
self.object_to_remove.save()
return self.object_to_remove
@@ -229,11 +226,9 @@ class RemoveModalForm(BaseModalForm):
action = UserActionLogEntry.objects.create(
user=self.user,
timestamp=timezone.now(),
action=UserActionLogEntryEnum.DELETED.value,
action=UserAction.DELETED,
)
self.instance.deleted = action
#self.instance.deleted_on = timezone.now()
#self.instance.deleted_by = self.user
self.instance.save()
else:
# If the class does not provide restorable delete functionality, we must delete the entry finally
@@ -297,7 +292,7 @@ class NewDocumentForm(BaseModalForm):
with transaction.atomic():
action = UserActionLogEntry.objects.create(
user=self.user,
action=UserActionLogEntryEnum.CREATED.value,
action=UserAction.CREATED,
)
doc = Document.objects.create(
created=action,

View File

@@ -12,7 +12,6 @@ from django.utils.translation import gettext_lazy as _
from django.contrib.gis.db.models import MultiPolygonField
from django.db import models
from konova.settings import DEFAULT_SRID
from user.models import UserActionLogEntry
@@ -120,4 +119,5 @@ class Geometry(BaseResource):
"""
Outsourced geometry model so multiple versions of the same object can refer to the same geometry if it is not changed
"""
from konova.settings import DEFAULT_SRID
geom = MultiPolygonField(null=True, blank=True, srid=DEFAULT_SRID)

View File

@@ -12,7 +12,6 @@ https://docs.djangoproject.com/en/3.1/ref/settings/
from django.utils.translation import gettext_lazy as _
# Load other settings
from konova.enums import ServerMessageImportance
from konova.sub_settings.django_settings import *
# Num of days if user enables Remember-me on login
@@ -55,12 +54,6 @@ DEFAULT_GROUP = "Default"
ZB_GROUP = "Registration office"
ETS_GROUP = "Conservation office"
# ServerMessageImportance bootstrap resolver
SVI_BOOTSTRAP_CLS_MAP = {
ServerMessageImportance.DEFAULT.value: "",
ServerMessageImportance.WARNING.value: "alert-danger",
ServerMessageImportance.INFO.value: "alert-info",
}
# HELP PAGE LINK
HELP_LINK = "https://dienste.naturschutz.rlp.de/doku/doku.php?id=ksp:start"

View File

@@ -6,11 +6,19 @@ Created on: 05.07.21
"""
from django import template
from konova.settings import SVI_BOOTSTRAP_CLS_MAP
# Create custom library
from news.models import ServerMessageImportance
register = template.Library()
# ServerMessageImportance bootstrap resolver
SVI_BOOTSTRAP_CLS_MAP = {
ServerMessageImportance.DEFAULT.name: "",
ServerMessageImportance.WARNING.name: "alert-danger",
ServerMessageImportance.INFO.name: "alert-info",
}
@register.filter("bootstrap_cls")
def bootstrap_cls(value):