From 7a5e0ab170c3a43860bc04bb8eee429ef7efb46f Mon Sep 17 00:00:00 2001 From: Etzelia Date: Sat, 22 Sep 2018 23:36:37 -0500 Subject: [PATCH] New property on IP model last_used_formatted - Returns last_used if valid, else "N/A" --- models.py | 7 +++++++ templates/minecraft_manager/ip.html | 2 +- templates/minecraft_manager/player_info.html | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/models.py b/models.py index dacd021..a3d72ae 100644 --- a/models.py +++ b/models.py @@ -375,6 +375,13 @@ class IP(models.Model): verbose_name = "IP" verbose_name_plural = "IPs" + @property + def last_used_formatted(self): + if self.last_used: + return self.last_used + else: + return "N/A" + @property def associated(self): ips = IP.objects.filter(ip=self.ip) diff --git a/templates/minecraft_manager/ip.html b/templates/minecraft_manager/ip.html index ec1023e..c8e51ac 100644 --- a/templates/minecraft_manager/ip.html +++ b/templates/minecraft_manager/ip.html @@ -14,7 +14,7 @@ {% for i in ips %} {{ i.player.username }} - {{ i.last_used }} + {{ i.last_used_formatted }} {% endfor %} diff --git a/templates/minecraft_manager/player_info.html b/templates/minecraft_manager/player_info.html index ed33468..653eeec 100644 --- a/templates/minecraft_manager/player_info.html +++ b/templates/minecraft_manager/player_info.html @@ -59,7 +59,7 @@ {% for ip in form.ips %} - {{ ip.ip }} ({{ ip.last_used }}) + {{ ip.ip }} ({{ ip.last_used_formatted }}) {% if ip.associated %} {% for assoc in ip.associated %}