New property on IP model

last_used_formatted - Returns last_used if valid, else "N/A"
reminder
Etzelia 2018-09-22 23:36:37 -05:00
parent bfe310f636
commit 7a5e0ab170
3 changed files with 9 additions and 2 deletions

View File

@ -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)

View File

@ -14,7 +14,7 @@
{% for i in ips %}
<tr>
<td><a href="{% url "player" %}{{ i.player.id }}">{{ i.player.username }}</a></td>
<td>{{ i.last_used }}</td>
<td>{{ i.last_used_formatted }}</td>
</tr>
{% endfor %}
</tbody>

View File

@ -59,7 +59,7 @@
{% for ip in form.ips %}
<tr class="default" data-id="" data-url="{% url 'ip' ip.id %}">
<!-- {{ ip.id }} -->
<td>{{ ip.ip }} ({{ ip.last_used }})</td>
<td>{{ ip.ip }} ({{ ip.last_used_formatted }})</td>
{% if ip.associated %}
<td>
{% for assoc in ip.associated %}