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_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)
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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 %}
|
||||
|
|
Loading…
Reference in New Issue