bloonsworld/app/bloonsa_game/views.py

44 lines
1.4 KiB
Python

import os
from django.shortcuts import render
from django.views.generic import TemplateView
from django.views.static import serve
from bloonsa_game.models import Level
from users.util import tag_player
class IndexView(TemplateView):
def get(self, request, *args, **kwargs):
tag_player(request=request)
return render(request, "bloonsa_game/index.html", context={})
class TermsView(TemplateView):
def get(self, request, *args, **kwargs):
tag_player(request=request)
return render(request, "bloonsa_game/terms.html", context={})
class GameView(TemplateView):
def get(self, request, *args, **kwargs):
tag_player(request=request)
if type(kwargs.get("pk")) is int:
level = Level.objects.get(id=kwargs["pk"])
if level:
return render(request, "bloonsa_game/level.html", context={
"flashVars": level.getFlashVars(seperator="&"),
"levelTitle": level.title,
"levelAuthor": level.author,
})
return render(request, "bloonsa_game/game.html", context={})
class WIPView(TemplateView):
def get(self, request, *args, **kwargs):
return render(request, "bloonsa_game/error.html", context={})
def post(self, request, *args, **kwargs):
return render(request, "bloonsa_game/error.html", context={})