-
+
{% trans 'Title' %} |
{{intervention.title|default_if_none:""}} |
-
+
{% trans 'Process type' %} |
{{intervention.legal.process_type|default_if_none:""}} |
-
+
{% trans 'Law' %} |
{{intervention.legal.law|default_if_none:""}} |
@@ -36,7 +36,7 @@
{% trans 'Registration office' %} |
{{intervention.responsible.registration_office|default_if_none:""}} |
-
+
{% trans 'Registration office file number' %} |
{{intervention.responsible.registration_file_number|default_if_none:""}} |
@@ -48,7 +48,7 @@
{% trans 'Conversation office file number' %} |
{{intervention.responsible.conservation_file_number|default_if_none:""}} |
-
+
{% trans 'Intervention handler' %} |
{{intervention.responsible.handler|default_if_none:""}} |
@@ -80,15 +80,15 @@
{% endif %}
-
+
{% trans 'Registration date' %} |
{{intervention.legal.registration_date|default_if_none:""}} |
-
+
{% trans 'Binding on' %} |
{{intervention.legal.binding_date|default_if_none:""}} |
-
+
{% trans 'Revocation' %} |
{{intervention.legal.revocation.date|naturalday|default_if_none:""}} |
diff --git a/intervention/urls.py b/intervention/urls.py
index 16ff259f..e580d4b9 100644
--- a/intervention/urls.py
+++ b/intervention/urls.py
@@ -8,7 +8,7 @@ Created on: 30.11.20
from django.urls import path
from intervention.views import index_view, new_view, open_view, edit_view, remove_view, new_document_view, share_view, \
- create_share_view, remove_revocation_view, new_revocation_view, run_check_view
+ create_share_view, remove_revocation_view, new_revocation_view, run_check_view, log_view
app_name = "intervention"
urlpatterns = [
@@ -16,6 +16,7 @@ urlpatterns = [
path('new/', new_view, name='new'),
path('/document/new/', new_document_view, name='new-doc'),
path('', open_view, name='open'),
+ path('/log', log_view, name='log'),
path('/edit', edit_view, name='edit'),
path('/remove', remove_view, name='remove'),
path('/share/', share_view, name='share'),
diff --git a/intervention/views.py b/intervention/views.py
index 03715cb8..5a7e9203 100644
--- a/intervention/views.py
+++ b/intervention/views.py
@@ -370,3 +370,25 @@ def new_revocation_view(request: HttpRequest, id: str):
raise NotImplementedError
+@login_required
+def log_view(request: HttpRequest, id: str):
+ """ Renders a log view using modal
+
+ Args:
+ request (HttpRequest): The incoming request
+ id (str): The compensation's id
+
+ Returns:
+
+ """
+ intervention = get_object_or_404(Intervention, id=id)
+ template = "modal/modal_generic.html"
+ body_template = "log.html"
+
+ context = {
+ "modal_body_template": body_template,
+ "log": intervention.log.all().order_by("-timestamp"),
+ "modal_title": _("Log"),
+ }
+ context = BaseContext(request, context).context
+ return render(request, template, context)
diff --git a/konova/forms.py b/konova/forms.py
index 31a474d5..36717d98 100644
--- a/konova/forms.py
+++ b/konova/forms.py
@@ -21,7 +21,7 @@ from django.utils import timezone
from django.utils.translation import gettext_lazy as _
from konova.contexts import BaseContext
-from konova.models import Document
+from konova.models import Document, BaseObject
from konova.utils.message_templates import FORM_INVALID
from user.models import UserActionLogEntry, UserAction
@@ -236,14 +236,16 @@ class RemoveModalForm(BaseModalForm):
self.form_caption = _("Are you sure?")
def save(self):
- if hasattr(self.instance, "deleted"):
- action = UserActionLogEntry.objects.create(
- user=self.user,
- timestamp=timezone.now(),
- action=UserAction.DELETED,
- )
- self.instance.deleted = action
- self.instance.save()
+ if isinstance(self.instance, BaseObject):
+ with transaction.atomic():
+ action = UserActionLogEntry.objects.create(
+ user=self.user,
+ timestamp=timezone.now(),
+ action=UserAction.DELETED,
+ )
+ self.instance.deleted = action
+ self.instance.log.add(action)
+ self.instance.save()
else:
# If the class does not provide restorable delete functionality, we must delete the entry finally
self.instance.delete()
@@ -317,4 +319,12 @@ class NewDocumentForm(BaseModalForm):
date_of_creation=self.cleaned_data["creation_date"],
)
self.instance.documents.add(doc)
- return doc
\ No newline at end of file
+
+ edited_action = UserActionLogEntry.objects.create(
+ user=self.user,
+ action=UserAction.EDITED,
+ comment=_("Added document"),
+ )
+ self.instance.log.add(edited_action)
+
+ return doc
diff --git a/konova/models.py b/konova/models.py
index 8743b480..043a9583 100644
--- a/konova/models.py
+++ b/konova/models.py
@@ -8,6 +8,7 @@ Created on: 17.11.20
import os
import uuid
+from django.contrib.auth.models import User
from django.utils.translation import gettext_lazy as _
from django.contrib.gis.db.models import MultiPolygonField
from django.db import models, transaction
@@ -54,6 +55,7 @@ class BaseObject(BaseResource):
title = models.CharField(max_length=1000, null=True, blank=True)
deleted = models.ForeignKey(UserActionLogEntry, on_delete=models.SET_NULL, null=True, blank=True, related_name='+')
comment = models.TextField(null=True, blank=True)
+ log = models.ManyToManyField(UserActionLogEntry, blank=True, help_text="Keeps all user actions of an object", editable=False)
class Meta:
abstract = True
@@ -83,6 +85,23 @@ class BaseObject(BaseResource):
self.deleted = action
self.save()
+ def add_log_entry(self, action: UserAction, user: User, comment: str):
+ """ Wraps adding of UserActionLogEntry to self.log
+
+ Args:
+ action (UserAction): The performed UserAction
+ user (User): Performing user
+
+ Returns:
+
+ """
+ user_action = UserActionLogEntry.objects.create(
+ user=user,
+ action=action,
+ comment=comment
+ )
+ self.log.add(user_action)
+
class DeadlineType(models.TextChoices):
"""
diff --git a/locale/de/LC_MESSAGES/django.mo b/locale/de/LC_MESSAGES/django.mo
index 602d85e8..fcc2b162 100644
Binary files a/locale/de/LC_MESSAGES/django.mo and b/locale/de/LC_MESSAGES/django.mo differ
diff --git a/locale/de/LC_MESSAGES/django.po b/locale/de/LC_MESSAGES/django.po
index eafe7eeb..d4953186 100644
--- a/locale/de/LC_MESSAGES/django.po
+++ b/locale/de/LC_MESSAGES/django.po
@@ -3,20 +3,20 @@
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR , YEAR.
#
-#: compensation/forms.py:34 compensation/forms.py:39 compensation/forms.py:52
-#: compensation/forms.py:182 compensation/forms.py:244
+#: compensation/forms.py:42 compensation/forms.py:47 compensation/forms.py:60
+#: compensation/forms.py:203 compensation/forms.py:271
#: intervention/filters.py:26 intervention/filters.py:40
#: intervention/filters.py:47 intervention/filters.py:48
-#: intervention/forms.py:323 intervention/forms.py:335
-#: intervention/forms.py:347 konova/forms.py:91 konova/forms.py:227
-#: konova/forms.py:258 konova/forms.py:263 konova/forms.py:275
-#: konova/forms.py:287 konova/forms.py:300 user/forms.py:38
+#: intervention/forms.py:318 intervention/forms.py:330
+#: intervention/forms.py:342 konova/forms.py:92 konova/forms.py:228
+#: konova/forms.py:261 konova/forms.py:266 konova/forms.py:278
+#: konova/forms.py:290 konova/forms.py:303 user/forms.py:38
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2021-08-04 15:12+0200\n"
+"POT-Creation-Date: 2021-08-05 12:43+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME \n"
"Language-Team: LANGUAGE \n"
@@ -26,140 +26,156 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
-#: compensation/forms.py:33 compensation/forms.py:233
+#: compensation/forms.py:41 compensation/forms.py:260
#: intervention/templates/intervention/detail/includes/eco-account-withdraws.html:33
msgid "Amount"
msgstr "Menge"
-#: compensation/forms.py:35
+#: compensation/forms.py:43
msgid "Amount in Euro"
msgstr "Betrag in Euro"
-#: compensation/forms.py:38
+#: compensation/forms.py:46
#: intervention/templates/intervention/detail/includes/payments.html:31
msgid "Due on"
msgstr "Fällig am"
-#: compensation/forms.py:40
+#: compensation/forms.py:48
msgid "Due on which date"
msgstr "Zahlung wird an diesem Datum erwartet"
-#: compensation/forms.py:53
+#: compensation/forms.py:61
msgid "Transfer note"
msgstr "Verwendungszweck"
-#: compensation/forms.py:54
+#: compensation/forms.py:62
msgid "Note for money transfer"
msgstr "Verwendungszweck für Überweisung"
-#: compensation/forms.py:60
+#: compensation/forms.py:68
msgid "Payment"
msgstr "Zahlung"
-#: compensation/forms.py:61
+#: compensation/forms.py:69
msgid "Add a payment for intervention '{}'"
msgstr "Neue Ersatzzahlung zu Eingriff '{}' hinzufügen"
-#: compensation/forms.py:81
+#: compensation/forms.py:80
+msgid "Added payment"
+msgstr "Zahlung hinzufügen"
+
+#: compensation/forms.py:95
msgid "Biotope Type"
msgstr "Biotoptyp"
-#: compensation/forms.py:84
+#: compensation/forms.py:98
msgid "Select the biotope type"
msgstr "Biotoptyp wählen"
-#: compensation/forms.py:89
+#: compensation/forms.py:103
#: compensation/templates/compensation/detail/includes/states-after.html:36
#: compensation/templates/compensation/detail/includes/states-before.html:36
msgid "Surface"
msgstr "Fläche"
-#: compensation/forms.py:92
+#: compensation/forms.py:106
msgid "in m²"
msgstr ""
-#: compensation/forms.py:97
+#: compensation/forms.py:111
msgid "New state"
msgstr "Neuer Zustand"
-#: compensation/forms.py:98
+#: compensation/forms.py:112
msgid "Insert data for the new state"
msgstr "Geben Sie die Daten des neuen Zustandes ein"
-#: compensation/forms.py:112 konova/forms.py:141
+#: compensation/forms.py:119
+msgid "Added state"
+msgstr "Zustand hinzugefügt"
+
+#: compensation/forms.py:133 konova/forms.py:142
msgid "Object removed"
msgstr "Objekt entfernt"
-#: compensation/forms.py:154
+#: compensation/forms.py:175
msgid "Deadline Type"
msgstr "Fristart"
-#: compensation/forms.py:157
+#: compensation/forms.py:178
msgid "Select the deadline type"
msgstr "Fristart wählen"
-#: compensation/forms.py:166
+#: compensation/forms.py:187
#: compensation/templates/compensation/detail/includes/deadlines.html:31
-#: intervention/forms.py:322
+#: intervention/forms.py:317
msgid "Date"
msgstr "Datum"
-#: compensation/forms.py:169
+#: compensation/forms.py:190
msgid "Select date"
msgstr "Datum wählen"
-#: compensation/forms.py:181 compensation/forms.py:243
+#: compensation/forms.py:202 compensation/forms.py:270
#: compensation/templates/compensation/detail/includes/actions.html:34
#: compensation/templates/compensation/detail/includes/deadlines.html:34
#: compensation/templates/compensation/detail/includes/documents.html:31
-#: intervention/forms.py:346
+#: intervention/forms.py:341
#: intervention/templates/intervention/detail/includes/documents.html:31
#: intervention/templates/intervention/detail/includes/revocation.html:35
-#: konova/forms.py:286
+#: konova/forms.py:289
msgid "Comment"
msgstr "Kommentar"
-#: compensation/forms.py:183 compensation/forms.py:245
-#: intervention/forms.py:348 konova/forms.py:288
+#: compensation/forms.py:204 compensation/forms.py:272
+#: intervention/forms.py:343 konova/forms.py:291
msgid "Additional comment, maximum {} letters"
msgstr "Zusätzlicher Kommentar, maximal {} Zeichen"
-#: compensation/forms.py:194
+#: compensation/forms.py:215
msgid "New deadline"
msgstr "Neue Frist"
-#: compensation/forms.py:195
+#: compensation/forms.py:216
msgid "Insert data for the new deadline"
msgstr "Geben Sie die Daten der neuen Frist ein"
-#: compensation/forms.py:215
+#: compensation/forms.py:233
+msgid "Added deadline"
+msgstr "Frist/Termin hinzugefügt"
+
+#: compensation/forms.py:242
msgid "Action Type"
msgstr "Maßnahmentyp"
-#: compensation/forms.py:218
+#: compensation/forms.py:245
msgid "Select the action type"
msgstr "Maßnahmentyp wählen"
-#: compensation/forms.py:221
+#: compensation/forms.py:248
msgid "Unit"
msgstr "Einheit"
-#: compensation/forms.py:224
+#: compensation/forms.py:251
msgid "Select the unit"
msgstr "Einheit wählen"
-#: compensation/forms.py:236
+#: compensation/forms.py:263
msgid "Insert the amount"
msgstr "Menge eingeben"
-#: compensation/forms.py:256
+#: compensation/forms.py:283
msgid "New action"
msgstr "Neue Maßnahme"
-#: compensation/forms.py:257
+#: compensation/forms.py:284
msgid "Insert data for the new action"
msgstr "Geben Sie die Daten der neuen Maßnahme ein"
+#: compensation/forms.py:302
+msgid "Added action"
+msgstr "Maßnahme hinzugefügt"
+
#: compensation/models.py:59
msgid "cm"
msgstr ""
@@ -196,7 +212,7 @@ msgstr "Kennung"
#: intervention/forms.py:35 intervention/tables.py:28
#: intervention/templates/intervention/detail/includes/compensations.html:33
#: intervention/templates/intervention/detail/includes/documents.html:28
-#: intervention/templates/intervention/detail/view.html:24 konova/forms.py:257
+#: intervention/templates/intervention/detail/view.html:24 konova/forms.py:260
msgid "Title"
msgstr "Bezeichnung"
@@ -265,7 +281,7 @@ msgstr "Für Sie freigegeben - Datensatz kann bearbeitet werden"
msgid "Access not granted"
msgstr "Nicht freigegeben - Datensatz nur lesbar"
-#: compensation/tables.py:174 konova/forms.py:262
+#: compensation/tables.py:174 konova/forms.py:265
msgid "Created on"
msgstr "Erstellt"
@@ -313,6 +329,7 @@ msgstr "Menge"
#: intervention/templates/intervention/detail/includes/eco-account-withdraws.html:36
#: intervention/templates/intervention/detail/includes/payments.html:37
#: intervention/templates/intervention/detail/includes/revocation.html:41
+#: templates/log.html:10
msgid "Action"
msgstr "Aktionen"
@@ -336,6 +353,10 @@ msgid "Edit"
msgstr "Bearbeiten"
#: compensation/templates/compensation/detail/includes/controls.html:21
+msgid "Show log"
+msgstr "Log anzeigen"
+
+#: compensation/templates/compensation/detail/includes/controls.html:24
#: intervention/templates/intervention/detail/includes/controls.html:36
#: venv/lib/python3.7/site-packages/django/forms/formsets.py:391
msgid "Delete"
@@ -365,7 +386,7 @@ msgstr "Dokumente"
#: compensation/templates/compensation/detail/includes/documents.html:14
#: intervention/templates/intervention/detail/includes/documents.html:14
-#: konova/forms.py:299
+#: konova/forms.py:302
msgid "Add new document"
msgstr "Neues Dokument hinzufügen"
@@ -434,54 +455,58 @@ msgstr "Verzeichnet am"
msgid "Last modified"
msgstr "Zuletzt bearbeitet"
-#: compensation/templates/compensation/detail/view.html:74
-#: intervention/forms.py:256
-#: intervention/templates/intervention/detail/view.html:106
+#: compensation/templates/compensation/detail/view.html:72
+#: intervention/forms.py:251
+#: intervention/templates/intervention/detail/view.html:104
msgid "Shared with"
msgstr "Freigegeben für"
-#: compensation/templates/compensation/detail/view.html:86
-#: intervention/templates/intervention/detail/view.html:118
+#: compensation/templates/compensation/detail/view.html:84
+#: intervention/templates/intervention/detail/view.html:116
msgid "No geometry added, yet."
msgstr "Keine Geometrie vorhanden"
-#: compensation/views.py:121
+#: compensation/views.py:127
+msgid "Log"
+msgstr "Log"
+
+#: compensation/views.py:148
msgid "Compensation removed"
msgstr "Kompensation entfernt"
-#: compensation/views.py:201
+#: compensation/views.py:228
msgid "Payment added"
msgstr "Zahlung hinzugefügt"
-#: compensation/views.py:236
+#: compensation/views.py:263
msgid "Payment removed"
msgstr "Zahlung gelöscht"
-#: compensation/views.py:262
+#: compensation/views.py:289
msgid "Withdraw removed"
msgstr "Abbuchung entfernt"
-#: compensation/views.py:280 intervention/views.py:96
+#: compensation/views.py:307 intervention/views.py:96
msgid "Document added"
msgstr "Dokument hinzugefügt"
-#: compensation/views.py:299
+#: compensation/views.py:326
msgid "State added"
msgstr "Zustand hinzugefügt"
-#: compensation/views.py:318
+#: compensation/views.py:345
msgid "Action added"
msgstr "Maßnahme hinzugefügt"
-#: compensation/views.py:337
+#: compensation/views.py:364
msgid "Deadline added"
msgstr "Frist hinzugefügt"
-#: compensation/views.py:356
+#: compensation/views.py:383
msgid "State removed"
msgstr "Zustand gelöscht"
-#: compensation/views.py:375
+#: compensation/views.py:402
msgid "Action removed"
msgstr "Maßnahme entfernt"
@@ -563,45 +588,45 @@ msgstr "Dateien"
msgid "New intervention"
msgstr "Neuer Eingriff"
-#: intervention/forms.py:151
+#: intervention/forms.py:146
msgid "Edit intervention"
msgstr "Eingriff bearbeiten"
-#: intervention/forms.py:245
+#: intervention/forms.py:240
msgid "Share link"
msgstr "Freigabelink"
-#: intervention/forms.py:247
+#: intervention/forms.py:242
msgid "Send this link to users who you want to have writing access on the data"
msgstr "Andere Nutzer erhalten über diesen Link Zugriff auf die Daten"
-#: intervention/forms.py:259
+#: intervention/forms.py:254
msgid "Remove check to remove access for this user"
msgstr "Wählen Sie die Nutzer ab, die keinen Zugriff mehr haben sollen"
-#: intervention/forms.py:270
+#: intervention/forms.py:265
#: intervention/templates/intervention/detail/includes/controls.html:15
msgid "Share"
msgstr "Freigabe"
-#: intervention/forms.py:271
+#: intervention/forms.py:266
msgid "Share settings for {}"
msgstr "Freigabe Einstellungen für {}"
-#: intervention/forms.py:324
+#: intervention/forms.py:319
msgid "Date of revocation"
msgstr "Datum des Widerspruchs"
-#: intervention/forms.py:334
+#: intervention/forms.py:329
#: intervention/templates/intervention/detail/includes/revocation.html:38
msgid "Document"
msgstr "Dokument"
-#: intervention/forms.py:336 konova/forms.py:276
+#: intervention/forms.py:331 konova/forms.py:279
msgid "Must be smaller than 15 Mb"
msgstr "Muss kleiner als 15 Mb sein"
-#: intervention/forms.py:359
+#: intervention/forms.py:354
#: intervention/templates/intervention/detail/includes/revocation.html:18
msgid "Add revocation"
msgstr "Widerspruch hinzufügen"
@@ -823,35 +848,39 @@ msgstr ""
msgid "You need to be part of another user group."
msgstr "Hierfür müssen Sie einer anderen Nutzergruppe angehören!"
-#: konova/forms.py:64
+#: konova/forms.py:65
msgid "Not editable"
msgstr "Nicht editierbar"
-#: konova/forms.py:90 konova/forms.py:226
+#: konova/forms.py:91 konova/forms.py:227
msgid "Confirm"
msgstr "Bestätige"
-#: konova/forms.py:102 konova/forms.py:235
+#: konova/forms.py:103 konova/forms.py:236
msgid "Remove"
msgstr "Löschen"
-#: konova/forms.py:104
+#: konova/forms.py:105
msgid "You are about to remove {} {}"
msgstr "Sie sind dabei {} {} zu löschen"
-#: konova/forms.py:236
+#: konova/forms.py:237
msgid "Are you sure?"
msgstr "Sind Sie sicher?"
-#: konova/forms.py:264
+#: konova/forms.py:267
msgid "When has this file been created? Important for photos."
msgstr "Wann wurde diese Datei erstellt oder das Foto aufgenommen?"
-#: konova/forms.py:274
+#: konova/forms.py:277
#: venv/lib/python3.7/site-packages/django/db/models/fields/files.py:231
msgid "File"
msgstr "Datei"
+#: konova/forms.py:327
+msgid "Added document"
+msgstr "Dokument hinzugefügt"
+
#: konova/management/commands/setup_data.py:42
msgid "On new related data"
msgstr "Wenn neue Daten für mich angelegt werden"
@@ -876,19 +905,19 @@ msgstr "Wenn meine freigegebenen Daten gelöscht wurden"
msgid "On registered data edited"
msgstr "Wenn meine freigegebenen Daten bearbeitet wurden"
-#: konova/models.py:92
+#: konova/models.py:110
msgid "Finished"
msgstr "Umgesetzt bis"
-#: konova/models.py:93
+#: konova/models.py:111
msgid "Maintain"
msgstr "Unterhaltung bis"
-#: konova/models.py:94
+#: konova/models.py:112
msgid "Control"
msgstr "Kontrolle am"
-#: konova/models.py:95
+#: konova/models.py:113
msgid "Other"
msgstr "Sonstige"
@@ -1012,6 +1041,14 @@ msgstr ""
msgid "Apply filter"
msgstr "Filter anwenden"
+#: templates/log.html:7
+msgid "Timestamp"
+msgstr ""
+
+#: templates/log.html:13
+msgid "User"
+msgstr "Nutzer"
+
#: templates/modal/modal_form.html:25
msgid "Continue"
msgstr "Weiter"
@@ -1101,6 +1138,10 @@ msgid "Created"
msgstr "Erstellt"
#: user/models.py:51
+msgid "Edited"
+msgstr "Bearbeitet"
+
+#: user/models.py:52
msgid "Deleted"
msgstr "Gelöscht"
@@ -2342,9 +2383,6 @@ msgstr ""
#~ msgid "Missing surfaces: "
#~ msgstr "Fehlende Flächen: "
-#~ msgid "Show all"
-#~ msgstr "Alle anzeigen"
-
#~ msgid "This will remove '{}'. Are you sure?"
#~ msgstr "Hiermit wird '{}' gelöscht. Sind Sie sicher?"
diff --git a/templates/log.html b/templates/log.html
new file mode 100644
index 00000000..acc2ee67
--- /dev/null
+++ b/templates/log.html
@@ -0,0 +1,33 @@
+{% load i18n %}
+
\ No newline at end of file
diff --git a/templates/modal/modal_generic.html b/templates/modal/modal_generic.html
new file mode 100644
index 00000000..5e0f6b89
--- /dev/null
+++ b/templates/modal/modal_generic.html
@@ -0,0 +1,17 @@
+{% load i18n l10n %}
+{% comment %}
+ A generic modal template which is derived from modal_form.html on django-bootstrap-modal-forms package
+ https://pypi.org/project/django-bootstrap-modal-forms/
+{% endcomment %}
+
+
+
+
+
+ {% include modal_body_template %}
+
\ No newline at end of file
diff --git a/user/models.py b/user/models.py
index 53a5ca7a..ebeb5cff 100644
--- a/user/models.py
+++ b/user/models.py
@@ -48,6 +48,7 @@ class UserAction(models.TextChoices):
CHECKED = "checked", _("Checked")
RECORDED = "recorded", _("Recorded")
CREATED = "created", _("Created")
+ EDITED = "edited", _("Edited")
DELETED = "deleted", _("Deleted")
@@ -70,6 +71,22 @@ class UserActionLogEntry(models.Model):
help_text="Short name for performed action - optional",
choices=UserAction.choices,
)
+ comment = models.CharField(max_length=255, null=True, blank=True, help_text="Additional comment on this entry")
def __str__(self):
- return "{} | {} | {}".format(self.user.username, self.timestamp, self.action)
\ No newline at end of file
+ return "{} | {} | {}".format(self.user.username, self.timestamp, self.action)
+
+ @property
+ def action_humanize(self):
+ """ Returns humanized version of enum
+
+ Used for template rendering
+
+ Returns:
+
+ """
+ choices = UserAction.choices
+ for choice in choices:
+ if choice[0] == self.action:
+ return choice[1]
+ return None