From 569c5b73ee170f707460812c90dfe4ebeb377388 Mon Sep 17 00:00:00 2001 From: "A. Svensson" Date: Wed, 18 Feb 2015 21:30:50 +0100 Subject: [PATCH] Added current_players to Server. --- .../management/commands/update_population.py | 1 + .../migrations/0005_auto_20150218_2029.py | 24 +++++++++++++++++++ src/gameservers/models.py | 3 ++- 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 src/gameservers/migrations/0005_auto_20150218_2029.py diff --git a/src/gameservers/management/commands/update_population.py b/src/gameservers/management/commands/update_population.py index 6189a62..d6f4e79 100755 --- a/src/gameservers/management/commands/update_population.py +++ b/src/gameservers/management/commands/update_population.py @@ -100,6 +100,7 @@ class Command(BaseCommand): defaults= dict( game_url=data['game_url'], site_url=data['site_url'] or '', + current_players=data['player_count'], ) ) diff --git a/src/gameservers/migrations/0005_auto_20150218_2029.py b/src/gameservers/migrations/0005_auto_20150218_2029.py new file mode 100644 index 0000000..86d2087 --- /dev/null +++ b/src/gameservers/migrations/0005_auto_20150218_2029.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('gameservers', '0004_auto_20150218_1915'), + ] + + operations = [ + migrations.AlterModelOptions( + name='server', + options={'ordering': ['-current_players', 'title']}, + ), + migrations.AddField( + model_name='server', + name='current_players', + field=models.PositiveIntegerField(default=0), + preserve_default=True, + ), + ] diff --git a/src/gameservers/models.py b/src/gameservers/models.py index 63bea83..91e6666 100644 --- a/src/gameservers/models.py +++ b/src/gameservers/models.py @@ -4,9 +4,10 @@ class Server(models.Model): title = models.CharField(max_length=255) game_url = models.URLField() site_url = models.URLField(blank=True) + current_players = models.PositiveIntegerField(default=0) class Meta: - ordering = ['title'] + ordering = ['-current_players', 'title'] def __str__(self): return self.title