Show server status on the server list.

This commit is contained in:
A. Svensson 2015-03-10 20:12:32 +01:00
parent 95ef380a3c
commit 039e81977c
3 changed files with 21 additions and 0 deletions

View File

View File

@ -0,0 +1,12 @@
from django import template
from django.utils import timezone
register = template.Library()
@register.filter
def hours_since_now(timestamp):
delta = timezone.now() - timestamp
return delta.total_seconds() / 3600.0

View File

@ -1,5 +1,6 @@
{% extends "base_site.html" %} {% extends "base_site.html" %}
{% load staticfiles %} {% load staticfiles %}
{% load server_utils %}
{% block title %} {% block title %}
Index Index
@ -15,7 +16,15 @@
</thead> </thead>
<tbody> <tbody>
{% for server in server_list %} {% for server in server_list %}
{% with delta_hours=server.last_updated|hours_since_now %}
{% if delta_hours > 24 %}
<tr class="danger">
{% elif delta_hours >= 1 %}
<tr class="warning">
{% else %}
<tr> <tr>
{% endif %}
{% endwith %}
<th>{{server.players_current}}</th> <th>{{server.players_current}}</th>
<th> <th>
<a href="{% url 'gameservers:detail' pk=server.id slug=server %}"> <a href="{% url 'gameservers:detail' pk=server.id slug=server %}">