Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

# -*- coding: utf-8 -*- 

from __future__ import unicode_literals 

 

from django.shortcuts import render 

from rest_framework import generics 

from .models import * 

from .serializers import * 

 

 

# Create your views here. 

 

class ListDriverView(generics.ListAPIView): 

""" 

Provides a get method handler. 

""" 

queryset = Driver.objects.all() 

serializer_class = DriverSerializer 

 

class ListRaceView(generics.ListAPIView): 

queryset = Race.objects.all() 

serializer_class = RaceSerializer 

 

class ListRelayView(generics.ListAPIView): 

queryset = Relay.objects.all() 

serializer_class = RelaySerializer 

 

class ListRulesView(generics.ListAPIView): 

queryset = Rules.objects.all() 

serializer_class = RulesSerializer 

 

class ListTeamView(generics.ListAPIView): 

queryset = Team.objects.all() 

serializer_class = TeamSerializer 

 

class ListEngagedPilotView(generics.ListAPIView): 

queryset = EngagedPilot.objects.all() 

serializer_class = EngagedPilotSerializer 

 

class ListRelaysByRaceAndTeamView(generics.ListAPIView): 

serializer_class = ListRelaysByRaceAndTeamSerializer 

def get_queryset(self): 

raceid = self.kwargs['raceid'] 

return Race.objects.filter(id=raceid) 

 

"""  

def get_queryset(self): 

raceid = self.kwargs['raceid'] 

teamid = self.kwargs['teamid'] 

return Relay.objects.filter(team_pilot__team=teamid).filter(team_pilot__race=raceid) 

 

class ListRelaysByRaceAndTeamView(generics.ListAPIView): 

#Getting the params from the url with the "self.kwargs.get"  

#and filter with thoses in the relays relation 

serializer_class = RelayPilotSerializer 

lookup_url_raceid = "raceid" 

lookup_url_teamid = "teamid" 

 

def get_queryset(self): 

raceid = self.kwargs.get(self.lookup_url_raceid) 

teamid = self.kwargs.get(self.lookup_url_teamid) 

relays = Relay.objects.filter(team_pilot__team=teamid).filter(team_pilot__race=raceid) 

return relays 

"""