Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
Remove usage of 'force anonymous' switch
Browse files Browse the repository at this point in the history
LEARNER-5664
  • Loading branch information
jmyatt committed Jul 2, 2018
1 parent 7f2a124 commit c6c5934
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
3 changes: 1 addition & 2 deletions ecommerce/extensions/api/v2/tests/views/test_baskets.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from oscar.test import factories
from oscar.test.factories import BasketFactory
from rest_framework.throttling import UserRateThrottle
from waffle.testutils import override_flag, override_switch
from waffle.testutils import override_flag

from ecommerce.courses.models import Course
from ecommerce.extensions.api import exceptions as api_exceptions
Expand Down Expand Up @@ -582,7 +582,6 @@ def test_basket_calculate_does_not_call_tracking_events(self):

@mock.patch('ecommerce.extensions.api.v2.views.baskets.BasketCalculateView._calculate_temporary_basket')
@override_flag('disable_calculate_temporary_basket_atomic_transaction', active=True)
@override_switch('force_anonymous_user_response_for_basket_calculate', active=True)
def test_basket_calculate_anonymous_caching(self, mock_calculate_basket):
"""Verify a request made with the is_anonymous parameter is cached"""
url_with_one_sku = self._generate_sku_url(self.products[0:1], username=None)
Expand Down
15 changes: 3 additions & 12 deletions ecommerce/extensions/api/v2/views/baskets.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,13 +471,8 @@ def get(self, request): # pylint: disable=too-many-statements

basket_owner = request.user

if waffle.switch_is_active("force_anonymous_user_response_for_basket_calculate"):
# Use the anonymous user program price for all users
requested_username = ''
is_anonymous = True
else:
requested_username = request.GET.get('username', default='')
is_anonymous = request.GET.get('is_anonymous', 'false').lower() == 'true'
requested_username = request.GET.get('username', default='')
is_anonymous = request.GET.get('is_anonymous', 'false').lower() == 'true'

use_default_basket = is_anonymous

Expand Down Expand Up @@ -528,11 +523,7 @@ def get(self, request): # pylint: disable=too-many-statements
if cached_response.is_hit:
return Response(cached_response.value)

# There are too many open questions around dropping the atomic transaction for a user's basket,
# including how user basket merges was coded. For now, only allow disabling the atomic
# transaction if we are also forcing the anonymous basket response for all users.
if waffle.flag_is_active(request, "disable_calculate_temporary_basket_atomic_transaction")\
and waffle.switch_is_active("force_anonymous_user_response_for_basket_calculate"):
if waffle.flag_is_active(request, "disable_calculate_temporary_basket_atomic_transaction"):
response = self._calculate_temporary_basket(basket_owner, request, products, voucher, skus, code)
else:
response = self._calculate_temporary_basket_atomic(basket_owner, request, products, voucher, skus, code)
Expand Down

0 comments on commit c6c5934

Please sign in to comment.