Exemplo n.º 1
0
 def _choose_cart_by_user_or_by_id(cls, cart_by_id: Cart,
                                   cart_by_user: Cart) -> Cart:
     if cart_by_id != cart_by_user:
         if cart_by_id.user is not None and cart_by_id.user != cart_by_user.user:
             return cart_by_user
         if cart_by_user.get_courses_count != 0:
             cart_by_id.delete()
             return cart_by_user
         else:
             if cart_by_id.user is None:
                 cart_by_id.user = cart_by_user.user
                 cart_by_id.save()
             cart_by_user.delete()
             return cart_by_id
     return cart_by_id