Skip to content

Commit

Permalink
Merge pull request #5793 from uktrade/feature/remove-export-wins-feat…
Browse files Browse the repository at this point in the history
…ure-flag

Remove feature flag for viewing legacy export wins.
  • Loading branch information
elcct authored Nov 15, 2024
2 parents 0631d0e + 2914ee8 commit 8b331fd
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 43 deletions.
3 changes: 0 additions & 3 deletions datahub/export_win/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
EXPORT_WINS_LEGACY_DATA_FEATURE_FLAG_NAME = (
'export-wins-legacy-data',
)
28 changes: 2 additions & 26 deletions datahub/export_win/test/test_win_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@
create_test_user,
format_date_or_datetime,
)
from datahub.export_win import (
EXPORT_WINS_LEGACY_DATA_FEATURE_FLAG_NAME,
)
from datahub.export_win.models import (
CustomerResponse,
CustomerResponseToken,
Expand All @@ -54,23 +51,11 @@
WinAdviserFactory,
WinFactory,
)
from datahub.feature_flag.test.factories import UserFeatureFlagFactory
from datahub.metadata.test.factories import TeamFactory

pytestmark = pytest.mark.django_db


@pytest.fixture()
def export_wins_legacy_data_feature_flag():
"""
Creates the Export wins legacy data user feature flag.
"""
yield UserFeatureFlagFactory(
code=EXPORT_WINS_LEGACY_DATA_FEATURE_FLAG_NAME,
is_active=True,
)


@pytest.fixture()
def export_wins():
confirmed = CustomerResponseFactory.create_batch(
Expand Down Expand Up @@ -476,17 +461,8 @@ def test_list(self):

assert response_data['count'] == 2

@pytest.mark.parametrize(
'list_legacy_data',
(
True,
False,
),
)
def test_list_with_legacy_wins(self, list_legacy_data, export_wins_legacy_data_feature_flag):
def test_list_with_legacy_wins(self):
"""Tests listing wins."""
if list_legacy_data:
self.user.features.set([export_wins_legacy_data_feature_flag])
WinFactory.create_batch(2, adviser=self.user)
WinFactory.create_batch(2, adviser=self.user, migrated_on=now())
url = reverse('api-v4:export-win:collection')
Expand All @@ -495,7 +471,7 @@ def test_list_with_legacy_wins(self, list_legacy_data, export_wins_legacy_data_f
assert response.status_code == status.HTTP_200_OK
response_data = response.json()

assert response_data['count'] == (4 if list_legacy_data else 2)
assert response_data['count'] == 4

def test_list_default_sorting(self):
"""Tests wins are sorted."""
Expand Down
15 changes: 1 addition & 14 deletions datahub/export_win/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from datahub.core.schemas import StubSchema

from datahub.core.viewsets import CoreViewSet
from datahub.export_win import EXPORT_WINS_LEGACY_DATA_FEATURE_FLAG_NAME
from datahub.export_win.decorators import validate_script_and_html_tags
from datahub.export_win.models import (
CustomerResponse,
Expand All @@ -40,9 +39,7 @@
notify_export_win_email_by_rq_email,
update_customer_response_token_for_email_notification_id,
)
from datahub.feature_flag.utils import (
is_user_feature_flag_active,
)


logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -131,21 +128,11 @@ class WinViewSet(CoreViewSet):

def get_queryset(self):
"""Filter the queryset to the authenticated user."""
if is_user_feature_flag_active(
EXPORT_WINS_LEGACY_DATA_FEATURE_FLAG_NAME,
self.request.user,
):
migrated_filter = {}
else:
migrated_filter = {
'migrated_on__isnull': True,
}
return (
super()
.get_queryset()
.filter(
is_anonymous_win=False,
**migrated_filter,
)
.exclude(
~Q(adviser=self.request.user),
Expand Down

0 comments on commit 8b331fd

Please sign in to comment.