diff --git a/src/gameservers/management/commands/update_population.py b/src/gameservers/management/commands/update_population.py index 7f329fe..b1a3289 100755 --- a/src/gameservers/management/commands/update_population.py +++ b/src/gameservers/management/commands/update_population.py @@ -97,6 +97,7 @@ class Command(BaseCommand): servers = parser.run() for data in servers: + # TODO: do bulk insert instead! server, created = Server.objects.get_or_create( title=data['title'], game_url=data['game_url'], diff --git a/src/gameservers/views.py b/src/gameservers/views.py index 91ea44a..7c0bf10 100644 --- a/src/gameservers/views.py +++ b/src/gameservers/views.py @@ -1,3 +1,17 @@ from django.shortcuts import render +from django.views import generic + +from .models import Server, Population + +class ServerListView(generic.ListView): + model = Server + +class ServerDetailView(generic.DetailView): + model = Server + + def get_context_data(self, **kwargs): + context = super(ServerDetailView, self).get_context_data(**kwargs) + # HACK: 24 hours for the last 3 days, might want to change this + context['population'] = Population.objects.all()[:3*24] + return context -# Create your views here.