diff --git a/BookingSystem/inventory.py b/BookingSystem/inventory.py
index b77d1ab..3c5d83b 100644
--- a/BookingSystem/inventory.py
+++ b/BookingSystem/inventory.py
@@ -71,6 +71,19 @@ def order_due_date_fmt(self) -> str:
return ''
return parser.parse(self.order_due_date).strftime('%d.%m.%Y')
+ @property
+ def last_seen_td_html(self) -> str:
+ if not self.last_seen:
+ return ''
+ parsed = parser.parse(self.last_seen)
+ # Show last seen within 3hrs as new (color in table)
+ within_3hrs = 'class="last-seen-new"' if parsed > datetime.now() - timedelta(hours=3) else ''
+ # 1yr = 1 school year (300 days) (color in table)
+ over_1yr = 'class="last-seen-old"' if parsed < datetime.now() - timedelta(days=300) else ''
+ inject_class = f'{within_3hrs}{over_1yr}'
+ # Construct HTML
+ return f"
{parsed.strftime('%d.%m.%Y')} | "
+
@property
def user(self) -> dict:
if self.borrowed_to is None:
diff --git a/BookingSystem/templates/inventar.html b/BookingSystem/templates/inventar.html
index 9b5f7cd..94f3f39 100644
--- a/BookingSystem/templates/inventar.html
+++ b/BookingSystem/templates/inventar.html
@@ -37,7 +37,7 @@ Her kan du legge til og endre inventaren. Du kan også skrive ut etiketter.<
{{ item.id }} |
{{ item.name }} |
{{ item.category }} |
- {{ item.last_seen }} |
+ {{ item.last_seen_td_html | safe }}
{% if item.available %}
Rediger
diff --git a/BookingSystem/templates/partials/css.html b/BookingSystem/templates/partials/css.html
index 0162405..a608510 100644
--- a/BookingSystem/templates/partials/css.html
+++ b/BookingSystem/templates/partials/css.html
@@ -48,6 +48,14 @@
color: var(--form-element-color);
}
+ .last-seen-new {
+ color: var(--form-element-valid-active-border-color);
+ }
+
+ .last-seen-old {
+ color: var(--form-element-invalid-active-border-color);
+ }
+
/* Use the same max-width as body main */
@media (min-width: 1200px) {
#bulletin-contents {
|