コード例 #1
0
ファイル: views.py プロジェクト: mdek/flightloggin2
def tailnumber_profile(request, tn):

    types = Plane.objects\
                 .filter(hidden=False)\
                 .filter(tailnumber__iexact=tn)\
                 .values_list('type', flat=True)\
                 .exclude(type="")\
                 .order_by()\
                 .distinct()

    models = Plane.objects\
                 .filter(hidden=False)\
                 .filter(tailnumber__iexact=tn)\
                 .values_list('model', flat=True)\
                 .exclude(model="")\
                 .order_by()\
                 .distinct()

    users = Plane.get_profiles(tailnumber=tn)

    t = Flight.objects\
              .filter(plane__tailnumber__iexact=tn)\
              .filter(plane__hidden=False)\

    t_hours = t.aggregate(s=Sum('total'))['s']
    t_flights = t.count()

    routes = Route.objects.filter(flight__plane__tailnumber=tn,
                                  flight__plane__hidden=False)

    return locals()
コード例 #2
0
ファイル: views.py プロジェクト: mdek/flightloggin2
def type_profile(request, ty):

    ## the users who have flown this type
    users = Plane.get_profiles(type=ty)

    t_hours = Flight.objects\
                    .filter(plane__type__iexact=ty)\
                    .aggregate(s=Sum('total'))['s']

    t_flights = Flight.objects.filter(plane__type__iexact=ty).count()

    u_airports = Location.objects\
                         .filter(routebase__route__flight__plane__type__iexact=ty,
                                 loc_class__lte=2)\
                         .order_by()\
                         .distinct()\
                         .count()

    tailnumbers = Plane.objects\
                       .values_list('tailnumber', flat=True)\
                       .filter(type__iexact=ty)\
                       .order_by()\
                       .distinct()

    return locals()
コード例 #3
0
ファイル: views.py プロジェクト: bovine/flightloggin2
def tailnumber_profile(request, tn):
    
    types = Plane.objects\
                 .filter(hidden=False)\
                 .filter(tailnumber__iexact=tn)\
                 .values_list('type', flat=True)\
                 .exclude(type="")\
                 .order_by()\
                 .distinct()
                 
    models = Plane.objects\
                 .filter(hidden=False)\
                 .filter(tailnumber__iexact=tn)\
                 .values_list('model', flat=True)\
                 .exclude(model="")\
                 .order_by()\
                 .distinct()
    
    users = Plane.get_profiles(tailnumber=tn)
    
    t = Flight.objects\
              .filter(plane__tailnumber__iexact=tn)\
              .filter(plane__hidden=False)\
                    
    t_hours = t.aggregate(s=Sum('total'))['s']             
    t_flights = t.count()
    
    routes = Route.objects.filter(flight__plane__tailnumber=tn,
                                  flight__plane__hidden=False)
    
    return locals()
コード例 #4
0
ファイル: views.py プロジェクト: bovine/flightloggin2
def type_profile(request, ty):
    
    ## the users who have flown this type
    users = Plane.get_profiles(type=ty)
    
    t_hours = Flight.objects\
                    .filter(plane__type__iexact=ty)\
                    .aggregate(s=Sum('total'))['s'] 
    
    t_flights = Flight.objects.filter(plane__type__iexact=ty).count()
    
    u_airports = Location.objects\
                         .filter(routebase__route__flight__plane__type__iexact=ty,
                                 loc_class__lte=2)\
                         .order_by()\
                         .distinct()\
                         .count()
    
    tailnumbers = Plane.objects\
                       .values_list('tailnumber', flat=True)\
                       .filter(type__iexact=ty)\
                       .order_by()\
                       .distinct()
    
    return locals()
コード例 #5
0
ファイル: views.py プロジェクト: bovine/flightloggin2
def model_profile(request, model):
    
    url_model = model
    model = model.replace('_', ' ')
    
    ## the users who have flown this type
    users = Plane.get_profiles(model=model)
    
    # total hours in model
    t_hours = Flight.objects\
                    .filter(plane__model__iexact=model)\
                    .aggregate(s=Sum('total'))['s'] 
    
    # total flights in model
    t_flights = Flight.objects.filter(plane__model__iexact=model).count()
    
    # unique airports
    u_airports = Location.objects\
                         .filter(routebase__route__flight__plane__model__iexact=model,
                                 loc_class__lte=2)\
                         .order_by()\
                         .distinct()\
                         .count()
    
    # tailnumbers of this model
    tailnumbers = Plane.objects\
                       .values_list('tailnumber', flat=True)\
                       .filter(model__iexact=model)\
                       .order_by()\
                       .distinct()
    
    avg_speed = Flight.objects\
                      .user('ALL')\
                      .filter(plane__model__iexact=model)\
                      .exclude(speed__lte=30)\
                      .exclude(app__gt=1)\
                      .exclude(route__total_line_all__lt=50)\
                      .aggregate(s=Avg('speed'))['s'] 
                      
    
    return locals()
コード例 #6
0
ファイル: views.py プロジェクト: mdek/flightloggin2
def model_profile(request, model):

    url_model = model
    model = model.replace('_', ' ')

    ## the users who have flown this type
    users = Plane.get_profiles(model=model)

    # total hours in model
    t_hours = Flight.objects\
                    .filter(plane__model__iexact=model)\
                    .aggregate(s=Sum('total'))['s']

    # total flights in model
    t_flights = Flight.objects.filter(plane__model__iexact=model).count()

    # unique airports
    u_airports = Location.objects\
                         .filter(routebase__route__flight__plane__model__iexact=model,
                                 loc_class__lte=2)\
                         .order_by()\
                         .distinct()\
                         .count()

    # tailnumbers of this model
    tailnumbers = Plane.objects\
                       .values_list('tailnumber', flat=True)\
                       .filter(model__iexact=model)\
                       .order_by()\
                       .distinct()

    avg_speed = Flight.objects\
                      .user('ALL')\
                      .filter(plane__model__iexact=model)\
                      .exclude(speed__lte=30)\
                      .exclude(app__gt=1)\
                      .exclude(route__total_line_all__lt=50)\
                      .aggregate(s=Avg('speed'))['s']

    return locals()