Changed Population to PopulationHistory.
This commit is contained in:
parent
569c5b73ee
commit
a8e54ece4c
@ -1,13 +1,13 @@
|
||||
from django.contrib import admin
|
||||
|
||||
from .models import Server, Population
|
||||
from .models import Server, PopulationHistory
|
||||
|
||||
class ServerAdmin(admin.ModelAdmin):
|
||||
list_display = ['title', 'site_url']
|
||||
|
||||
class PopulationAdmin(admin.ModelAdmin):
|
||||
class PopulationHistoryAdmin(admin.ModelAdmin):
|
||||
list_display = ['timestamp', 'server', 'players']
|
||||
|
||||
admin.site.register(Server, ServerAdmin)
|
||||
admin.site.register(Population, PopulationAdmin)
|
||||
admin.site.register(PopulationHistory, PopulationHistoryAdmin)
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
from gameservers.models import Server, Population
|
||||
from gameservers.models import Server, PopulationHistory
|
||||
|
||||
import re
|
||||
import logging
|
||||
@ -104,7 +104,7 @@ class Command(BaseCommand):
|
||||
)
|
||||
)
|
||||
|
||||
pop = Population.objects.create(
|
||||
pop = PopulationHistory.objects.create(
|
||||
server=server,
|
||||
players=data['player_count'],
|
||||
)
|
||||
|
||||
34
src/gameservers/migrations/0006_auto_20150218_2033.py
Normal file
34
src/gameservers/migrations/0006_auto_20150218_2033.py
Normal file
@ -0,0 +1,34 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('gameservers', '0005_auto_20150218_2029'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='PopulationHistory',
|
||||
fields=[
|
||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||
('timestamp', models.DateTimeField(auto_now_add=True)),
|
||||
('players', models.PositiveIntegerField()),
|
||||
('server', models.ForeignKey(to='gameservers.Server')),
|
||||
],
|
||||
options={
|
||||
'ordering': ['timestamp', 'server'],
|
||||
},
|
||||
bases=(models.Model,),
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='population',
|
||||
name='server',
|
||||
),
|
||||
migrations.DeleteModel(
|
||||
name='Population',
|
||||
),
|
||||
]
|
||||
@ -12,7 +12,7 @@ class Server(models.Model):
|
||||
def __str__(self):
|
||||
return self.title
|
||||
|
||||
class Population(models.Model):
|
||||
class PopulationHistory(models.Model):
|
||||
timestamp = models.DateTimeField(auto_now_add=True)
|
||||
server = models.ForeignKey(Server)
|
||||
players = models.PositiveIntegerField()
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
from django.shortcuts import render
|
||||
from django.views import generic
|
||||
|
||||
from .models import Server, Population
|
||||
from .models import Server, PopulationHistory
|
||||
|
||||
class ServerListView(generic.ListView):
|
||||
model = Server
|
||||
@ -13,6 +13,6 @@ class ServerDetailView(generic.DetailView):
|
||||
context = super(ServerDetailView, self).get_context_data(**kwargs)
|
||||
server = context['server']
|
||||
# HACK: 24 hours for the last 3 days, might want to change this
|
||||
context['population'] = Population.objects.filter(server=server)[:3*24]
|
||||
context['population'] = PopulationHistory.objects.filter(server=server)[:3*24]
|
||||
return context
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user