Updated the views and templates to reflect the new server model.
This commit is contained in:
parent
cd50deac5a
commit
b1b712ebee
@ -13,23 +13,6 @@ class ServerDetailView(generic.DetailView):
|
|||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(ServerDetailView, self).get_context_data(**kwargs)
|
context = super(ServerDetailView, self).get_context_data(**kwargs)
|
||||||
server = context['server']
|
server = context['server']
|
||||||
context['weekly_history'] = server.get_history_stats(days=7)
|
context['weekly_history'] = server.get_stats_history(days=7)
|
||||||
|
|
||||||
stats = server.calc_player_stats(days=1)
|
|
||||||
context['daily_average'] = stats['players__avg']
|
|
||||||
context['daily_min'] = stats['players__min']
|
|
||||||
context['daily_max'] = stats['players__max']
|
|
||||||
|
|
||||||
stats = server.calc_player_stats(days=7)
|
|
||||||
context['weekly_average'] = stats['players__avg']
|
|
||||||
context['weekly_min'] = stats['players__min']
|
|
||||||
context['weekly_max'] = stats['players__max']
|
|
||||||
|
|
||||||
stats = server.calc_player_stats(days=31)
|
|
||||||
context['monthly_average'] = stats['players__avg']
|
|
||||||
context['monthly_min'] = stats['players__min']
|
|
||||||
context['monthly_max'] = stats['players__max']
|
|
||||||
|
|
||||||
context['weekday_averages'] = server.weekday_averages()
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|||||||
@ -6,9 +6,7 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>
|
<h1>{{server}}</h1>
|
||||||
{{server}}
|
|
||||||
</h1>
|
|
||||||
|
|
||||||
<a class="btn btn-default" href="{{server.game_url}}" rel="nofollow">Launch game</a>
|
<a class="btn btn-default" href="{{server.game_url}}" rel="nofollow">Launch game</a>
|
||||||
{% if server.site_url %}
|
{% if server.site_url %}
|
||||||
@ -17,42 +15,32 @@
|
|||||||
<button class="btn btn-default">No homepage</button>
|
<button class="btn btn-default">No homepage</button>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<h2>Player Population</h2>
|
<h3>Players</h3>
|
||||||
<p>Currently <span class="bold">
|
|
||||||
{{server.current_players}} players
|
|
||||||
</span>online.</p>
|
|
||||||
|
|
||||||
<p>Last updated <span class="bold" title="{{server.last_updated|date:'r'}} GMT">
|
<p>Last updated <span class="bold" title="{{server.last_updated|date:'r'}} GMT">
|
||||||
{{server.last_updated|timesince}}
|
{{server.last_updated|timesince}}
|
||||||
</span>ago.</p>
|
</span>ago.</p>
|
||||||
|
|
||||||
<table class="table table-hover">
|
<table class="table table-hover">
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Time period</th>
|
|
||||||
<th>Average</th>
|
|
||||||
<th>Min</th>
|
|
||||||
<th>Max</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
{% if server.players_current > 0 %}
|
||||||
<th>Last day</th>
|
<tr class="success">
|
||||||
<th>{{daily_average|floatformat}}</th>
|
{% else %}
|
||||||
<th>{{daily_min}}</th>
|
<tr class="danger">
|
||||||
<th>{{daily_max}}</th>
|
{% endif %}
|
||||||
|
<th>Current</th>
|
||||||
|
<th>{{server.players_current}}</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Last week</th>
|
<th>Average</th>
|
||||||
<th>{{weekly_average|floatformat}}</th>
|
<th>{{server.players_avg}}</th>
|
||||||
<th>{{weekly_min}}</th>
|
|
||||||
<th>{{weekly_max}}</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Last month</th>
|
<th>Min</th>
|
||||||
<th>{{monthly_average|floatformat}}</th>
|
<th>{{server.players_min}}</th>
|
||||||
<th>{{monthly_min}}</th>
|
</tr>
|
||||||
<th>{{monthly_max}}</th>
|
<tr>
|
||||||
|
<th>Max</th>
|
||||||
|
<th>{{server.players_max}}</th>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
{% for server in server_list %}
|
{% for server in server_list %}
|
||||||
<tr>
|
<tr>
|
||||||
<th>{{server.current_players}}</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 %}">
|
||||||
{{server}}
|
{{server}}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user