def get_times_with_directions(self, number, tp, stop, day): tp = TatType.objects.get(title=tp) stop = Stop.objects.get(title=stop) route = Route.objects.get(Q(tat_number=number), Q(tat_type__id=tp.id)) d = Direction.objects.filter(route__id=route.id) waypoint = Waypoint.objects.filter(stop__id=stop.id, direction__in=d) return WaypointTime.objects.filter(waypoint__in=waypoint, weekdays=humanized_days_to_flags(day)).order_by('waypoint__direction__title')
def get_routes(self, **kw): day, time, title, stop_id = kw.get('day'), kw.get('time'), kw.get('title'), kw.get('stop_id') if title: waypoint = Waypoint.objects.filter(stop__title__contains=title) elif stop_id: waypoint = Waypoint.objects.filter(stop__id=stop_id) return WaypointTime.objects.filter(time__gt=time, waypoint__in=waypoint, weekdays=humanized_days_to_flags(day)).order_by('time')
def get_times(self, number, tp, stop, day, time, n=10): tp = TatType.objects.get(title=tp) stop = Stop.objects.get(title=stop) route = Route.objects.get(Q(tat_number=number), Q(tat_type__id=tp.id)) d = Direction.objects.filter(route__id=route.id) waypoint = Waypoint.objects.filter(stop__id=stop.id, direction__in=d) return WaypointTime.objects.filter(time__gt=time, waypoint__in=waypoint, weekdays=humanized_days_to_flags(day)).all()[:n]