Skip to content

Commit

Permalink
database: robustify WebIf against empty DB entries
Browse files Browse the repository at this point in the history
  • Loading branch information
aschwith committed Jan 8, 2024
1 parent d06ba27 commit 0ea42a7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
3 changes: 2 additions & 1 deletion database/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,6 @@ def db_lastchange(self, item):
This is a public function of the plugin
:param item: Item to get the ID for
:param cur: A database cursor object if available (optional)
:return: id of the item within the database
:rtype: int | None
Expand All @@ -512,6 +511,8 @@ def db_lastchange(self, item):

id = int(row[COL_ITEM_ID])
last_change = row[COL_ITEM_TIME]
if last_change is None:
return None
return self._datetime(last_change)


Expand Down
15 changes: 14 additions & 1 deletion database/webif/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,20 @@
<tr>
<td></td>
<td id="{{ item }}_orphan_path">{{ item }}</td>
<td id="{{ item }}_orphan_time">{% if language == 'en' %}{{ p.db_lastchange(item).strftime('%m/%d/%Y %H:%M:%S') }}{% else %}{{ p.db_lastchange(item).strftime('%d.%m.%Y %H:%M:%S') }}{% endif %}</td>
<td id="{{ item }}_orphan_time">
{% if language == 'en' %}
{% if p.db_lastchange(item) is none %}
{{ _('Wert invalide') }}
{% else %}
{{ p.db_lastchange(item).strftime('%m/%d/%Y %H:%M:%S') }}
{% endif %}
{% else %}
{% if p.db_lastchange(item) is none %}
{{ _('Wert invalide') }}
{% else %}
{{ p.db_lastchange(item).strftime('%d.%m.%Y %H:%M:%S') }}
{% endif %}
{% endif %}</td>
<td id="{{ item }}_orphan_type">{{ _(p.db_itemtype(item)) }}</td>
<td id="{{ item }}_orphan_id">{{ p.id(item, create=False) }}</td>
{% if p.count_logentries %}
Expand Down

0 comments on commit 0ea42a7

Please sign in to comment.