def fetch_inmates(self, start_date, end_date): if start_date is None and end_date is None: return CountyInmate.objects.filter() s_date = convert_to_date(start_date) if start_date is not None else None e_date = convert_to_date(end_date) if end_date is not None else None if s_date is None: return CountyInmate.objects.filter(booking_date__lte=e_date) elif e_date is None: return CountyInmate.objects.filter(booking_date__gte=s_date) return CountyInmate.objects.filter(booking_date__gte=s_date, booking_date__lte=e_date)
def fetch_inmates(self, start_date, end_date): if start_date is None and end_date is None: return CountyInmate.objects.filter() s_date = convert_to_date( start_date) if start_date is not None else None e_date = convert_to_date(end_date) if end_date is not None else None if s_date is None: return CountyInmate.objects.filter(booking_date__lte=e_date) elif e_date is None: return CountyInmate.objects.filter(booking_date__gte=s_date) return CountyInmate.objects.filter(booking_date__gte=s_date, booking_date__lte=e_date)
def end_date(self, day): today = date.today() if day: e_date = convert_to_date(day) if e_date < today: return e_date return today - self.ONE_DAY
def start_date(self, day): if day is None: day = self.START_DATE return convert_to_date(day)