registrasion/controllers/conditions.py
def pre_filter(self, queryset, user):
        ''' Returns all of the items from queryset where the date falls into
        any specified range, but not yet where the stock limit is not yet
        reached.'''

        now = timezone.now()

        # Keep items with no start time, or start time not yet met.
        queryset = queryset.filter(Q(start_time=None) | Q(start_time__lte=now))
        queryset = queryset.filter(Q(end_time=None) | Q(end_time__gte=now))

        # Filter out items that have been reserved beyond the limits
        quantity_or_zero = self._calculate_quantities(user)

        remainder = Case(
            When(limit=None, then=Value(_BIG_QUANTITY)),
            default=F("limit") - Sum(quantity_or_zero),
        )

        queryset = queryset.annotate(remainder=remainder)
        queryset = queryset.filter(remainder__gt=0)

        return queryset
def pre_filter(self, queryset, user):
        ''' Returns all of the items from queryset where the date falls into
        any specified range, but not yet where the stock limit is not yet
        reached.'''

        now = timezone.now()

        # Keep items with no start time, or start time not yet met.
        queryset = queryset.filter(Q(start_time=None) | Q(start_time__lte=now))
        queryset = queryset.filter(Q(end_time=None) | Q(end_time__gte=now))

        # Filter out items that have been reserved beyond the limits
        quantity_or_zero = self._calculate_quantities(user)

        remainder = Case(
            When(limit=None, then=Value(_BIG_QUANTITY)),
            default=F("limit") - Sum(quantity_or_zero),
        )

        queryset = queryset.annotate(remainder=remainder)
        queryset = queryset.filter(remainder__gt=0)

        return queryset
def pre_filter ( self , queryset , user ) : now = timezone . now ( ) # Keep items with no start time, or start time not yet met. queryset = queryset . filter ( Q ( start_time = None ) | Q ( start_time__lte = now ) ) queryset = queryset . filter ( Q ( end_time = None ) | Q ( end_time__gte = now ) ) # Filter out items that have been reserved beyond the limits quantity_or_zero = self . _calculate_quantities ( user ) remainder = Case ( When ( limit = None , then = Value ( _BIG_QUANTITY ) ) , default = F ( "limit" ) - Sum ( quantity_or_zero ) , ) queryset = queryset . annotate ( remainder = remainder ) queryset = queryset . filter ( remainder__gt = 0 ) return queryset
Returns all of the items from queryset where the date falls into
        any specified range, but not yet where the stock limit is not yet
        reached.
Returns all of the items from queryset where the date falls into any specified range but not yet where the stock limit is not yet reached .