Skip to content

Commit

Permalink
Fix sort audit by unix time
Browse files Browse the repository at this point in the history
  • Loading branch information
sondregronas committed Sep 5, 2023
1 parent 7b6b69b commit 0355145
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion BookingSystem/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import flask
from dateutil import parser
from flask_minify import Minify
from flask_session import Session
from werkzeug.middleware.proxy_fix import ProxyFix

import api
Expand All @@ -16,7 +17,6 @@
import user
from __init__ import logger, REGEX_ID, REGEX_ITEM, MIN_DAYS, MAX_DAYS, MIN_LABELS, MAX_LABELS
from db import init_db, Settings
from flask_session import Session


def create_app() -> flask.Flask:
Expand Down Expand Up @@ -49,6 +49,10 @@ def _jinja2_filter_datetime(date, fmt='%d.%m.%Y') -> str:
def _jinja2_filter_strftime(date, fmt='%d.%m.%Y') -> str:
return datetime.fromtimestamp(float(date)).strftime(fmt)

@app.template_filter('unixtime')
def _jinja2_filter_unixtime(date) -> int:
return int(parser.parse(date, dayfirst=True).timestamp())

@app.template_filter('split')
def _jinja2_filter_split(string, split_char=',') -> list:
return string.split(split_char)
Expand Down
2 changes: 1 addition & 1 deletion BookingSystem/templates/audits.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ <h3>Her kan du søke i loggen etter forlatt utstyr, hva skjedde med det?</h3>
<tbody>
{% for audit in audits %}
<tr>
<td>{{ audit.timestamp }}</td>
<td data-sort="{{ audit.timestamp | unixtime }}">{{ audit.timestamp }}</td>
<td>{{ audit.event }}</td>
<td>{{ audit.message }}</td>
</tr>
Expand Down

0 comments on commit 0355145

Please sign in to comment.