Created first app gameservers.

This commit is contained in:
A. Svensson 2015-02-18 17:11:21 +01:00
parent ef7055460c
commit f3281f0376
8 changed files with 83 additions and 0 deletions

View File

13
src/gameservers/admin.py Normal file
View File

@ -0,0 +1,13 @@
from django.contrib import admin
from .models import Server, Population
class ServerAdmin(admin.ModelAdmin):
list_display = ['title', 'site_url']
class PopulationAdmin(admin.ModelAdmin):
list_display = ['timestamp', 'server', 'players']
admin.site.register(Server, ServerAdmin)
admin.site.register(Population, PopulationAdmin)

View File

@ -0,0 +1,44 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
]
operations = [
migrations.CreateModel(
name='Population',
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()),
],
options={
'ordering': ['-timestamp', 'server'],
},
bases=(models.Model,),
),
migrations.CreateModel(
name='Server',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('title', models.CharField(max_length=255)),
('game_url', models.URLField()),
('site_url', models.URLField()),
],
options={
'ordering': ['-title'],
},
bases=(models.Model,),
),
migrations.AddField(
model_name='population',
name='server',
field=models.ForeignKey(to='gameservers.Server'),
preserve_default=True,
),
]

View File

18
src/gameservers/models.py Normal file
View File

@ -0,0 +1,18 @@
from django.db import models
class Server(models.Model):
title = models.CharField(max_length=255)
game_url = models.URLField()
site_url = models.URLField()
class Meta:
ordering = ['-title']
class Population(models.Model):
timestamp = models.DateTimeField(auto_now_add=True)
server = models.ForeignKey(Server)
players = models.PositiveIntegerField()
class Meta:
ordering = ['-timestamp', 'server']

3
src/gameservers/tests.py Normal file
View File

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

3
src/gameservers/views.py Normal file
View File

@ -0,0 +1,3 @@
from django.shortcuts import render
# Create your views here.

View File

@ -36,6 +36,8 @@ INSTALLED_APPS = (
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'gameservers',
)
MIDDLEWARE_CLASSES = (