from django.shortcuts import render from django.views.generic import TemplateView from bloonsa_game.models import Level from users.util import bloonsa_util, actions class IndexView(TemplateView): def get(self, request, *args, **kwargs): bloonsa_util.tag_player(request=request) return render(request, "bloonsa_game/index.html", context={}) class TermsView(TemplateView): def get(self, request, *args, **kwargs): bloonsa_util.tag_player(request=request) return render(request, "bloonsa_game/terms.html", context={}) class GameView(TemplateView): def get(self, request, *args, **kwargs): bloonsa_util.tag_player(request=request) # This init is for accounts made with 'createsuperuser' or originating from bloonsb player = bloonsa_util.init_player(request=request) # TODO get player object here with init_player to use in html template03.3.005 if type(kwargs.get("pk")) is int: level = Level.objects.get(id=kwargs["pk"]) if level: bloonsa_util.log(player=player, action=actions.bloonsa_load_level_by_url, note=level) return render(request, "bloonsa_game/level.html", context={ "player": player, "flashVars": level.getFlashVars(seperator="&"), "levelTitle": level.title, "levelAuthor": level.author, }) return render(request, "bloonsa_game/game.html", context={"player": player}) 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={})