コード例 #1
0
ファイル: views.py プロジェクト: raphv/marathonbackend
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})
コード例 #2
0
 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()
コード例 #3
0
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})
コード例 #4
0
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)
コード例 #5
0
ファイル: views.py プロジェクト: raphv/marathonbackend
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
コード例 #6
0
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
コード例 #7
0
ファイル: views.py プロジェクト: raphv/marathonbackend
 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()