from django.contrib.auth.forms import AuthenticationForm from django.shortcuts import render from django.views.generic import TemplateView # Create your views here. from bloonsa_game.models import Level class IndexView(TemplateView): def get(self, request, *args, **kwargs): return render(request, "bloonsa_game/index.html", context={}) class TermsView(TemplateView): def get(self, request, *args, **kwargs): return render(request, "bloonsa_game/terms.html", context={}) class GameView(TemplateView): def get(self, request, *args, **kwargs): 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={"login_form": AuthenticationForm()}) 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={})