registrasion/controllers/cart.py
def _autoextend_reservation(self):
        ''' Updates the cart's time last updated value, which is used to
        determine whether the cart has reserved the items and discounts it
        holds. '''

        time = timezone.now()

        # Calculate the residual of the _old_ reservation duration
        # if it's greater than what's in the cart now, keep it.
        time_elapsed_since_updated = (time - self.cart.time_last_updated)
        residual = self.cart.reservation_duration - time_elapsed_since_updated

        reservations = [datetime.timedelta(0), residual]

        # If we have vouchers, we're entitled to an hour at minimum.
        if len(self.cart.vouchers.all()) >= 1:
            reservations.append(inventory.Voucher.RESERVATION_DURATION)

        # Else, it's the maximum of the included products
        items = commerce.ProductItem.objects.filter(cart=self.cart)
        agg = items.aggregate(Max("product__reservation_duration"))
        product_max = agg["product__reservation_duration__max"]

        if product_max is not None:
            reservations.append(product_max)

        self.cart.time_last_updated = time
        self.cart.reservation_duration = max(reservations)
def _autoextend_reservation(self):
        ''' Updates the cart's time last updated value, which is used to
        determine whether the cart has reserved the items and discounts it
        holds. '''

        time = timezone.now()

        # Calculate the residual of the _old_ reservation duration
        # if it's greater than what's in the cart now, keep it.
        time_elapsed_since_updated = (time - self.cart.time_last_updated)
        residual = self.cart.reservation_duration - time_elapsed_since_updated

        reservations = [datetime.timedelta(0), residual]

        # If we have vouchers, we're entitled to an hour at minimum.
        if len(self.cart.vouchers.all()) >= 1:
            reservations.append(inventory.Voucher.RESERVATION_DURATION)

        # Else, it's the maximum of the included products
        items = commerce.ProductItem.objects.filter(cart=self.cart)
        agg = items.aggregate(Max("product__reservation_duration"))
        product_max = agg["product__reservation_duration__max"]

        if product_max is not None:
            reservations.append(product_max)

        self.cart.time_last_updated = time
        self.cart.reservation_duration = max(reservations)
def _autoextend_reservation ( self ) : time = timezone . now ( ) # Calculate the residual of the _old_ reservation duration # if it's greater than what's in the cart now, keep it. time_elapsed_since_updated = ( time - self . cart . time_last_updated ) residual = self . cart . reservation_duration - time_elapsed_since_updated reservations = [ datetime . timedelta ( 0 ) , residual ] # If we have vouchers, we're entitled to an hour at minimum. if len ( self . cart . vouchers . all ( ) ) >= 1 : reservations . append ( inventory . Voucher . RESERVATION_DURATION ) # Else, it's the maximum of the included products items = commerce . ProductItem . objects . filter ( cart = self . cart ) agg = items . aggregate ( Max ( "product__reservation_duration" ) ) product_max = agg [ "product__reservation_duration__max" ] if product_max is not None : reservations . append ( product_max ) self . cart . time_last_updated = time self . cart . reservation_duration = max ( reservations )
Updates the cart's time last updated value, which is used to
        determine whether the cart has reserved the items and discounts it
        holds.
Updates the cart s time last updated value which is used to determine whether the cart has reserved the items and discounts it holds .