def searchrunner(request): if 'runner_number' in request.GET or 'event' in request.GET: form = RunnerSearchForm(request.GET,request.user) else: form = RunnerSearchForm(None,request.user) if form.is_valid(): return HttpResponseRedirect(reverse('runner_results', kwargs={'event': request.GET["event"], 'runner_number': request.GET["runner_number"]})) return render(request, "searchrunner.html", {"runner_search_form": form})
def get_queryset(self): self.form = RunnerSearchForm(self.kwargs, self.request.user) if self.form.is_valid(): return RunnerTag.objects.select_related( "video__spectator,video__event").filter( video__event=self.form.cleaned_data["event"], runner_number=self.form.cleaned_data["runner_number"] ).order_by("time") else: return RunnerTag.objects.none()
def searchrunner(request): if 'runner_number' in request.GET or 'event' in request.GET: form = RunnerSearchForm(request.GET, request.user) else: form = RunnerSearchForm(None, request.user) if form.is_valid(): return HttpResponseRedirect( reverse('runner_results', kwargs={ 'event': request.GET["event"], 'runner_number': request.GET["runner_number"] })) return render(request, "searchrunner.html", {"runner_search_form": form})
def home(request): context = {} rtqs = RunnerTag.objects.filter(video__spectator__user=request.user) context["runnertags"] = rtqs.exclude(runner_number=-99).count() context["hottags"] = rtqs.filter(runner_number=-99).count() context["videos"] = Video.objects.filter( spectator__user=request.user).count() context["runner_search_form"] = RunnerSearchForm(None, request.user) return render(request, "home.html", context)
class RunnerTagList(ListView): template_name = "searchrunner.html" model = RunnerTag paginate_by = 12 def get_queryset(self): self.form = RunnerSearchForm(self.kwargs,self.request.user) if self.form.is_valid(): return RunnerTag.objects.select_related("video__spectator,video__event").filter(video__event=self.form.cleaned_data["event"],runner_number=self.form.cleaned_data["runner_number"]).order_by("time") else: return RunnerTag.objects.none() def get_context_data(self, **kwargs): context = super(RunnerTagList, self).get_context_data(**kwargs) context["runner_search_form"] = self.form context["GMAPS_API_KEY"] = settings.GMAPS_API_KEY return context
class RunnerTagList(ListView): template_name = "searchrunner.html" model = RunnerTag paginate_by = 12 def get_queryset(self): self.form = RunnerSearchForm(self.kwargs, self.request.user) if self.form.is_valid(): return RunnerTag.objects.select_related( "video__spectator,video__event").filter( video__event=self.form.cleaned_data["event"], runner_number=self.form.cleaned_data["runner_number"] ).order_by("time") else: return RunnerTag.objects.none() def get_context_data(self, **kwargs): context = super(RunnerTagList, self).get_context_data(**kwargs) context["runner_search_form"] = self.form context["GMAPS_API_KEY"] = settings.GMAPS_API_KEY return context
def get_queryset(self): self.form = RunnerSearchForm(self.kwargs,self.request.user) if self.form.is_valid(): return RunnerTag.objects.select_related("video__spectator,video__event").filter(video__event=self.form.cleaned_data["event"],runner_number=self.form.cleaned_data["runner_number"]).order_by("time") else: return RunnerTag.objects.none()