diff --git a/compensation/tables.py b/compensation/tables.py
index 401a7416..1373f2cd 100644
--- a/compensation/tables.py
+++ b/compensation/tables.py
@@ -5,17 +5,15 @@ Contact: michel.peltriaux@sgdnord.rlp.de
Created on: 01.12.20
"""
-from user.models import User
+from konova.utils.message_templates import DATA_IS_UNCHECKED, DATA_CHECKED_ON_TEMPLATE, DATA_CHECKED_PREVIOUSLY_TEMPLATE
from django.http import HttpRequest
from django.template.loader import render_to_string
from django.urls import reverse
from django.utils.html import format_html
-from django.utils.timezone import localtime
from django.utils.translation import gettext_lazy as _
from compensation.filters import CompensationTableFilter, EcoAccountTableFilter
from compensation.models import Compensation, EcoAccount
-from konova.sub_settings.django_settings import DEFAULT_DATE_TIME_FORMAT
from konova.utils.tables import BaseTable, TableRenderMixin
import django_tables2 as tables
@@ -111,16 +109,21 @@ class CompensationTable(BaseTable, TableRenderMixin):
"""
html = ""
checked = value is not None
- tooltip = _("Not checked yet")
+ tooltip = DATA_IS_UNCHECKED
+ previously_checked = record.intervention.get_last_checked_action()
if checked:
- value = value.timestamp
- value = localtime(value)
- checked_on = value.strftime(DEFAULT_DATE_TIME_FORMAT)
- tooltip = _("Checked on {} by {}").format(checked_on, record.intervention.checked.user)
+ checked_on = value.get_timestamp_str_formatted()
+ tooltip = DATA_CHECKED_ON_TEMPLATE.format(checked_on, record.intervention.checked.user)
html += self.render_checked_star(
tooltip=tooltip,
icn_filled=checked,
)
+ if previously_checked and not checked:
+ checked_on = previously_checked.get_timestamp_str_formatted()
+ tooltip = DATA_CHECKED_PREVIOUSLY_TEMPLATE.format(checked_on, previously_checked.user)
+ html += self.render_previously_checked_star(
+ tooltip=tooltip,
+ )
return format_html(html)
def render_d(self, value, record: Compensation):
@@ -159,9 +162,7 @@ class CompensationTable(BaseTable, TableRenderMixin):
recorded = value is not None
tooltip = _("Not recorded yet")
if recorded:
- value = value.timestamp
- value = localtime(value)
- on = value.strftime(DEFAULT_DATE_TIME_FORMAT)
+ on = value.get_timestamp_str_formatted()
tooltip = _("Recorded on {} by {}").format(on, record.intervention.recorded.user)
html += self.render_bookmark(
tooltip=tooltip,
@@ -179,8 +180,6 @@ class CompensationTable(BaseTable, TableRenderMixin):
Returns:
"""
- if value is None:
- value = User.objects.none()
has_access = record.is_shared_with(self.user)
html = self.render_icn(
@@ -318,9 +317,7 @@ class EcoAccountTable(BaseTable, TableRenderMixin):
checked = value is not None
tooltip = _("Not recorded yet. Can not be used for deductions, yet.")
if checked:
- value = value.timestamp
- value = localtime(value)
- on = value.strftime(DEFAULT_DATE_TIME_FORMAT)
+ on = value.get_timestamp_str_formatted()
tooltip = _("Recorded on {} by {}").format(on, record.recorded.user)
html += self.render_bookmark(
tooltip=tooltip,
diff --git a/compensation/templates/compensation/detail/compensation/view.html b/compensation/templates/compensation/detail/compensation/view.html
index 026a6ff6..be8dd3b9 100644
--- a/compensation/templates/compensation/detail/compensation/view.html
+++ b/compensation/templates/compensation/detail/compensation/view.html
@@ -66,6 +66,11 @@
{% fa5_icon 'star' 'far' %}
+ {% if last_checked %}
+
+ {% fa5_icon 'star' 'fas' %}
+
+ {% endif %}
{% else %}
{% fa5_icon 'star' %}
diff --git a/compensation/views/compensation.py b/compensation/views/compensation.py
index c3d3e2b5..31087ed7 100644
--- a/compensation/views/compensation.py
+++ b/compensation/views/compensation.py
@@ -23,7 +23,7 @@ from konova.utils.message_templates import FORM_INVALID, IDENTIFIER_REPLACED, DA
CHECKED_RECORDED_RESET, COMPENSATION_ADDED_TEMPLATE, COMPENSATION_REMOVED_TEMPLATE, DOCUMENT_ADDED, \
COMPENSATION_STATE_REMOVED, COMPENSATION_STATE_ADDED, COMPENSATION_ACTION_REMOVED, COMPENSATION_ACTION_ADDED, \
DEADLINE_ADDED, DEADLINE_REMOVED, DOCUMENT_EDITED, COMPENSATION_STATE_EDITED, COMPENSATION_ACTION_EDITED, \
- DEADLINE_EDITED, RECORDED_BLOCKS_EDIT, PARAMS_INVALID
+ DEADLINE_EDITED, RECORDED_BLOCKS_EDIT, PARAMS_INVALID, DATA_CHECKED_PREVIOUSLY_TEMPLATE
from konova.utils.user_checks import in_group
@@ -217,8 +217,15 @@ def detail_view(request: HttpRequest, id: str):
request = comp.set_status_messages(request)
+ last_checked = comp.intervention.get_last_checked_action()
+ last_checked_tooltip = ""
+ if last_checked:
+ last_checked_tooltip = DATA_CHECKED_PREVIOUSLY_TEMPLATE.format(last_checked.get_timestamp_str_formatted(), last_checked.user)
+
context = {
"obj": comp,
+ "last_checked": last_checked,
+ "last_checked_tooltip": last_checked_tooltip,
"geom_form": geom_form,
"parcels": parcels,
"has_access": is_data_shared,
diff --git a/ema/tables.py b/ema/tables.py
index 38d8a8c0..d26a31dc 100644
--- a/ema/tables.py
+++ b/ema/tables.py
@@ -115,7 +115,6 @@ class EmaTable(BaseTable, TableRenderMixin):
)
return html
-
def render_r(self, value, record: Ema):
""" Renders the registered column for a EMA
@@ -130,9 +129,7 @@ class EmaTable(BaseTable, TableRenderMixin):
recorded = value is not None
tooltip = _("Not recorded yet")
if recorded:
- value = value.timestamp
- value = localtime(value)
- on = value.strftime(DEFAULT_DATE_TIME_FORMAT)
+ on = value.get_timestamp_str_formatted()
tooltip = _("Recorded on {} by {}").format(on, record.recorded.user)
html += self.render_bookmark(
tooltip=tooltip,
diff --git a/intervention/tables.py b/intervention/tables.py
index 8f312099..cff9391c 100644
--- a/intervention/tables.py
+++ b/intervention/tables.py
@@ -9,12 +9,11 @@ from django.http import HttpRequest
from django.template.loader import render_to_string
from django.urls import reverse
from django.utils.html import format_html
-from django.utils.timezone import localtime
from django.utils.translation import gettext_lazy as _
from intervention.filters import InterventionTableFilter
from intervention.models import Intervention
-from konova.sub_settings.django_settings import DEFAULT_DATE_TIME_FORMAT, DEFAULT_DATE_FORMAT
+from konova.utils.message_templates import DATA_CHECKED_ON_TEMPLATE, DATA_IS_UNCHECKED, DATA_CHECKED_PREVIOUSLY_TEMPLATE
from konova.utils.tables import BaseTable, TableRenderMixin
import django_tables2 as tables
@@ -108,16 +107,21 @@ class InterventionTable(BaseTable, TableRenderMixin):
"""
html = ""
checked = value is not None
- tooltip = _("Not checked yet")
+ previously_checked = record.get_last_checked_action()
+ tooltip = DATA_IS_UNCHECKED
if checked:
- value = value.timestamp
- value = localtime(value)
- checked_on = value.strftime(DEFAULT_DATE_TIME_FORMAT)
- tooltip = _("Checked on {} by {}").format(checked_on, record.checked.user)
+ checked_on = value.get_timestamp_str_formatted()
+ tooltip = DATA_CHECKED_ON_TEMPLATE.format(checked_on, record.checked.user)
html += self.render_checked_star(
tooltip=tooltip,
icn_filled=checked,
)
+ if previously_checked and not checked:
+ checked_on = previously_checked.get_timestamp_str_formatted()
+ tooltip = DATA_CHECKED_PREVIOUSLY_TEMPLATE.format(checked_on, previously_checked.user)
+ html += self.render_previously_checked_star(
+ tooltip=tooltip,
+ )
return format_html(html)
def render_d(self, value, record: Intervention):
@@ -156,9 +160,7 @@ class InterventionTable(BaseTable, TableRenderMixin):
checked = value is not None
tooltip = _("Not recorded yet")
if checked:
- value = value.timestamp
- value = localtime(value)
- on = value.strftime(DEFAULT_DATE_TIME_FORMAT)
+ on = value.get_timestamp_str_formatted()
tooltip = _("Recorded on {} by {}").format(on, record.recorded.user)
html += self.render_bookmark(
tooltip=tooltip,
diff --git a/intervention/templates/intervention/detail/view.html b/intervention/templates/intervention/detail/view.html
index 55c9db99..55d57f68 100644
--- a/intervention/templates/intervention/detail/view.html
+++ b/intervention/templates/intervention/detail/view.html
@@ -70,6 +70,11 @@
{% fa5_icon 'star' 'far' %}
+ {% if last_checked %}
+
+ {% fa5_icon 'star' 'fas' %}
+
+ {% endif %}
{% else %}
{% fa5_icon 'star' %}
diff --git a/intervention/views.py b/intervention/views.py
index 15388dbf..36577202 100644
--- a/intervention/views.py
+++ b/intervention/views.py
@@ -19,7 +19,7 @@ from konova.utils.generators import generate_qr_code
from konova.utils.message_templates import INTERVENTION_INVALID, FORM_INVALID, IDENTIFIER_REPLACED, \
CHECKED_RECORDED_RESET, DEDUCTION_REMOVED, DEDUCTION_ADDED, REVOCATION_ADDED, REVOCATION_REMOVED, \
COMPENSATION_REMOVED_TEMPLATE, DOCUMENT_ADDED, DEDUCTION_EDITED, REVOCATION_EDITED, DOCUMENT_EDITED, \
- RECORDED_BLOCKS_EDIT
+ RECORDED_BLOCKS_EDIT, DATA_CHECKED_PREVIOUSLY_TEMPLATE
from konova.utils.user_checks import in_group
@@ -265,9 +265,15 @@ def detail_view(request: HttpRequest, id: str):
geom_form = SimpleGeomForm(
instance=intervention,
)
+ last_checked = intervention.get_last_checked_action()
+ last_checked_tooltip = ""
+ if last_checked:
+ last_checked_tooltip = DATA_CHECKED_PREVIOUSLY_TEMPLATE.format(last_checked.get_timestamp_str_formatted(), last_checked.user)
context = {
"obj": intervention,
+ "last_checked": last_checked,
+ "last_checked_tooltip": last_checked_tooltip,
"compensations": compensations,
"has_access": is_data_shared,
"geom_form": geom_form,
diff --git a/konova/models/object.py b/konova/models/object.py
index 780a0c2f..325762f4 100644
--- a/konova/models/object.py
+++ b/konova/models/object.py
@@ -408,6 +408,20 @@ class CheckableObjectMixin(models.Model):
self.log.add(action)
return action
+ def get_last_checked_action(self):
+ """ Getter for the most recent checked action on the log
+
+ Returns:
+ previously_checked (UserActionLogEntry): The most recent checked action
+ """
+ from user.models import UserAction
+ previously_checked = self.log.filter(
+ action=UserAction.CHECKED
+ ).order_by(
+ "-timestamp"
+ ).first()
+ return previously_checked
+
class ShareableObjectMixin(models.Model):
# Users having access on this object
diff --git a/konova/sub_settings/django_settings.py b/konova/sub_settings/django_settings.py
index e5de97a0..746df289 100644
--- a/konova/sub_settings/django_settings.py
+++ b/konova/sub_settings/django_settings.py
@@ -46,8 +46,8 @@ ALLOWED_HOSTS = [
LOGIN_URL = "/login/"
# Session settings
-#SESSION_COOKIE_AGE = 30 * 60 # 30 minutes
-#SESSION_SAVE_EVERY_REQUEST = True
+SESSION_COOKIE_AGE = 60 * 60 # 60 minutes
+SESSION_SAVE_EVERY_REQUEST = True
# Application definition
diff --git a/konova/templates/konova/includes/comment_card.html b/konova/templates/konova/includes/comment_card.html
index a84f378e..d9ea59bc 100644
--- a/konova/templates/konova/includes/comment_card.html
+++ b/konova/templates/konova/includes/comment_card.html
@@ -6,7 +6,7 @@
{% if obj.comment %}
-