def get_context_data(self, **kwargs): context = super(AirstripDetail, self).get_context_data(**kwargs) context['checkouts'] = util.airstrip_checkouts_grouped_by_pilot( self.object) return context
def test_multiple_pilots(self): airstrip1 = helper.create_airstrip('ID1', 'Airstrip1') airstrip2 = helper.create_airstrip('ID2', 'Airstrip2') c1 = helper.create_checkout(airstrip=airstrip1) c2 = helper.create_checkout(airstrip=airstrip2, pilot=c1.pilot, aircraft_type=c1.aircraft_type) results = [{ 'pilot_name': c1.pilot.full_name, 'pilot_slug': c1.pilot.username, 'airstrip_ident': airstrip1.ident, 'airstrip_name': airstrip1.name, 'actypes': { c1.aircraft_type.name: util.CHECKOUT_SUDAH, }, },] self.expected['aircraft_types'] = [c1.aircraft_type.name,] self.expected['results'] = results self.assertEqual(util.airstrip_checkouts_grouped_by_pilot(airstrip1), self.expected)
def test_empty(self): airstrip = helper.create_airstrip() self.assertEqual(util.airstrip_checkouts_grouped_by_pilot(airstrip), self.expected)