forked from Minecraft/minecraft_manager
New property on IP model
last_used_formatted - Returns last_used if valid, else "N/A"reminder
parent
bfe310f636
commit
7a5e0ab170
|
@ -375,6 +375,13 @@ class IP(models.Model):
|
||||||
verbose_name = "IP"
|
verbose_name = "IP"
|
||||||
verbose_name_plural = "IPs"
|
verbose_name_plural = "IPs"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def last_used_formatted(self):
|
||||||
|
if self.last_used:
|
||||||
|
return self.last_used
|
||||||
|
else:
|
||||||
|
return "N/A"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def associated(self):
|
def associated(self):
|
||||||
ips = IP.objects.filter(ip=self.ip)
|
ips = IP.objects.filter(ip=self.ip)
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
{% for i in ips %}
|
{% for i in ips %}
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="{% url "player" %}{{ i.player.id }}">{{ i.player.username }}</a></td>
|
<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>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
|
@ -59,7 +59,7 @@
|
||||||
{% for ip in form.ips %}
|
{% for ip in form.ips %}
|
||||||
<tr class="default" data-id="" data-url="{% url 'ip' ip.id %}">
|
<tr class="default" data-id="" data-url="{% url 'ip' ip.id %}">
|
||||||
<!-- {{ ip.id }} -->
|
<!-- {{ ip.id }} -->
|
||||||
<td>{{ ip.ip }} ({{ ip.last_used }})</td>
|
<td>{{ ip.ip }} ({{ ip.last_used_formatted }})</td>
|
||||||
{% if ip.associated %}
|
{% if ip.associated %}
|
||||||
<td>
|
<td>
|
||||||
{% for assoc in ip.associated %}
|
{% for assoc in ip.associated %}
|
||||||
|
|
Loading…
Reference in New Issue