Пример #1
0
 def calc_fuel(self):
     """
     Calculated the `gallons` and `mpg` database fields. It tries to use
     the fuel_burn value opn the flight but falls back to using the value
     associated with the plane if no value is present.
     """
     
     distance = self.route.total_line_all
     
     if self.fuel_burn or self.plane.fuel_burn:
         
         if self.fuel_burn:
             fb = FuelBurn(input=self.fuel_burn, time=self.total, mileage=distance)
         else:
             fb = FuelBurn(input=self.plane.fuel_burn, time=self.total, mileage=distance)
         
         self.gallons = fb.as_unit('gallons', for_db=True)
         self.gph = fb.as_unit('gph', for_db=True)
         self.mpg = fb.as_unit('mpg', for_db=True)
Пример #2
0
    def calc_fuel(self):
        """
        Calculated the `gallons` and `mpg` database fields. It tries to use
        the fuel_burn value opn the flight but falls back to using the value
        associated with the plane if no value is present.
        """

        distance = self.route.total_line_all

        if self.fuel_burn or self.plane.fuel_burn:

            if self.fuel_burn:
                fb = FuelBurn(input=self.fuel_burn,
                              time=self.total,
                              mileage=distance)
            else:
                fb = FuelBurn(input=self.plane.fuel_burn,
                              time=self.total,
                              mileage=distance)

            self.gallons = fb.as_unit('gallons', for_db=True)
            self.gph = fb.as_unit('gph', for_db=True)
            self.mpg = fb.as_unit('mpg', for_db=True)