Skip to content

Commit

Permalink
chore: remove deprecated functions url and ugettext_lazy (#3976)
Browse files Browse the repository at this point in the history
Co-authored-by: Matthew Elwell <matthew.elwell@flagsmith.com>
  • Loading branch information
gagantrivedi and matthewelwell committed May 18, 2024
1 parent f624223 commit e613eec
Show file tree
Hide file tree
Showing 14 changed files with 82 additions and 89 deletions.
10 changes: 6 additions & 4 deletions api/api/urls/deprecated.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.conf.urls import url
from django.urls import re_path

from environments.identities.traits.views import SDKTraitsDeprecated
from environments.identities.views import SDKIdentitiesDeprecated
Expand All @@ -7,10 +7,12 @@
app_name = "deprecated"

urlpatterns = [
url(
re_path(
r"^identities/(?P<identifier>[-\w@%.]+)/traits/(?P<trait_key>[-\w.]+)$",
SDKTraitsDeprecated.as_view(),
),
url(r"^identities/(?P<identifier>[-\w@%.]+)/", SDKIdentitiesDeprecated.as_view()),
url(r"^flags/(?P<identifier>[-\w@%.]+)$", SDKFeatureStates.as_view()),
re_path(
r"^identities/(?P<identifier>[-\w@%.]+)/", SDKIdentitiesDeprecated.as_view()
),
re_path(r"^flags/(?P<identifier>[-\w@%.]+)$", SDKFeatureStates.as_view()),
]
58 changes: 28 additions & 30 deletions api/api/urls/v1.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from app_analytics.views import SDKAnalyticsFlags, SelfHostedTelemetryAPIView
from django.conf import settings
from django.conf.urls import url
from django.urls import include, path
from django.urls import include, path, re_path
from drf_yasg import openapi
from drf_yasg.views import get_schema_view
from rest_framework import authentication, permissions, routers
Expand Down Expand Up @@ -32,44 +31,43 @@
app_name = "v1"

urlpatterns = [
url(r"^organisations/", include("organisations.urls"), name="organisations"),
url(r"^projects/", include("projects.urls"), name="projects"),
url(r"^environments/", include("environments.urls"), name="environments"),
url(r"^features/", include("features.urls"), name="features"),
url(r"^multivariate/", include("features.multivariate.urls"), name="multivariate"),
url(r"^segments/", include("segments.urls"), name="segments"),
url(r"^users/", include("users.urls")),
url(r"^e2etests/", include("e2etests.urls")),
url(r"^audit/", include("audit.urls")),
url(r"^auth/", include("custom_auth.urls")),
url(r"^metadata/", include("metadata.urls")),
re_path(r"^organisations/", include("organisations.urls"), name="organisations"),
re_path(r"^projects/", include("projects.urls"), name="projects"),
re_path(r"^environments/", include("environments.urls"), name="environments"),
re_path(r"^features/", include("features.urls"), name="features"),
re_path(
r"^multivariate/", include("features.multivariate.urls"), name="multivariate"
),
re_path(r"^segments/", include("segments.urls"), name="segments"),
re_path(r"^users/", include("users.urls")),
re_path(r"^e2etests/", include("e2etests.urls")),
re_path(r"^audit/", include("audit.urls")),
re_path(r"^auth/", include("custom_auth.urls")),
re_path(r"^metadata/", include("metadata.urls")),
# Chargebee webhooks
url(r"cb-webhook/", chargebee_webhook, name="chargebee-webhook"),
re_path(r"cb-webhook/", chargebee_webhook, name="chargebee-webhook"),
# GitHub integration webhook
url(r"github-webhook/", github_webhook, name="github-webhook"),
re_path(r"github-webhook/", github_webhook, name="github-webhook"),
re_path(r"cb-webhook/", chargebee_webhook, name="chargebee-webhook"),
# Client SDK urls
url(r"^flags/$", SDKFeatureStates.as_view(), name="flags"),
url(r"^identities/$", SDKIdentities.as_view(), name="sdk-identities"),
url(r"^traits/", include(traits_router.urls), name="traits"),
url(r"^analytics/flags/$", SDKAnalyticsFlags.as_view(), name="analytics-flags"),
url(
r"^analytics/telemetry/$",
SelfHostedTelemetryAPIView.as_view(),
name="analytics-telemetry",
),
url(
re_path(r"^flags/$", SDKFeatureStates.as_view(), name="flags"),
re_path(r"^identities/$", SDKIdentities.as_view(), name="sdk-identities"),
re_path(r"^traits/", include(traits_router.urls), name="traits"),
re_path(r"^analytics/flags/$", SDKAnalyticsFlags.as_view(), name="analytics-flags"),
re_path(r"^analytics/telemetry/$", SelfHostedTelemetryAPIView.as_view()),
re_path(
r"^environment-document/$",
SDKEnvironmentAPIView.as_view(),
name="environment-document",
),
url("", include("features.versioning.urls", namespace="versioning")),
re_path("", include("features.versioning.urls", namespace="versioning")),
# API documentation
url(
re_path(
r"^swagger(?P<format>\.json|\.yaml)$",
schema_view.without_ui(cache_timeout=0),
name="schema-json",
),
url(
re_path(
r"^docs/$",
schema_view.with_ui("swagger", cache_timeout=0),
name="schema-swagger-ui",
Expand All @@ -87,10 +85,10 @@
split_testing_router.register(r"", SplitTestViewSet, basename="split-tests")

urlpatterns += [
url(
re_path(
r"^split-testing/", include(split_testing_router.urls), name="split-testing"
),
url(
re_path(
r"^split-testing/conversion-events/",
CreateConversionEventView.as_view(),
name="conversion-events",
Expand Down
6 changes: 4 additions & 2 deletions api/api/urls/v2.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from app_analytics.views import SDKAnalyticsFlagsV2
from django.conf.urls import url
from django.urls import re_path

app_name = "v2"

urlpatterns = [
url(r"^analytics/flags/$", SDKAnalyticsFlagsV2.as_view(), name="analytics-flags")
re_path(
r"^analytics/flags/$", SDKAnalyticsFlagsV2.as_view(), name="analytics-flags"
)
]
27 changes: 13 additions & 14 deletions api/app/urls.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
import importlib

from django.conf import settings
from django.conf.urls import include, url
from django.contrib import admin
from django.urls import path
from django.urls import include, path, re_path
from django.views.generic.base import TemplateView

from users.views import password_reset_redirect

from . import views

urlpatterns = [
url(r"^api/v1/", include("api.urls.deprecated", namespace="api-deprecated")),
url(r"^api/v1/", include("api.urls.v1", namespace="api-v1")),
url(r"^api/v2/", include("api.urls.v2", namespace="api-v2")),
url(r"^admin/", admin.site.urls),
url(r"^health", include("health_check.urls", namespace="health")),
url(r"^version", views.version_info, name="version-info"),
url(
re_path(r"^api/v1/", include("api.urls.deprecated", namespace="api-deprecated")),
re_path(r"^api/v1/", include("api.urls.v1", namespace="api-v1")),
re_path(r"^api/v2/", include("api.urls.v2", namespace="api-v2")),
re_path(r"^admin/", admin.site.urls),
re_path(r"^health", include("health_check.urls", namespace="health")),
re_path(r"^version", views.version_info, name="version-info"),
re_path(
r"^sales-dashboard/",
include("sales_dashboard.urls", namespace="sales_dashboard"),
),
# this url is used to generate email content for the password reset workflow
url(
re_path(
r"^password-reset/confirm/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,"
r"13}-[0-9A-Za-z]{1,20})/$",
password_reset_redirect,
name="password_reset_confirm",
),
url(
re_path(
r"^config/project-overrides",
views.project_overrides,
name="project_overrides",
Expand All @@ -44,7 +43,7 @@
import debug_toolbar

urlpatterns = [
url(r"^__debug__/", include(debug_toolbar.urls)),
re_path(r"^__debug__/", include(debug_toolbar.urls)),
] + urlpatterns

if settings.SAML_INSTALLED:
Expand All @@ -68,6 +67,6 @@
]
)

if settings.SERVE_FE_ASSETS:
if settings.SERVE_FE_ASSETS: # pragma: no cover
# add route to serve FE assets for any unrecognised paths
urlpatterns.append(url(r"^.*$", views.index, name="index"))
urlpatterns.append(re_path(r"^.*$", views.index, name="index"))
4 changes: 2 additions & 2 deletions api/audit/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.conf.urls import include, url
from django.urls import include, re_path
from rest_framework import routers

from audit.views import AllAuditLogViewSet
Expand All @@ -7,4 +7,4 @@
router.register(r"", AllAuditLogViewSet, basename="audit")


urlpatterns = [url(r"^", include(router.urls))]
urlpatterns = [re_path(r"^", include(router.urls))]
4 changes: 2 additions & 2 deletions api/e2etests/urls.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from django.conf.urls import url
from django.urls import re_path

from .views import Teardown

app_name = "e2etests"


urlpatterns = [
url(r"teardown/", Teardown.as_view(), name="teardown"),
re_path(r"teardown/", Teardown.as_view(), name="teardown"),
]
3 changes: 1 addition & 2 deletions api/environments/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from django.db import models
from django.db.models import Prefetch, Q
from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
from django_lifecycle import (
AFTER_CREATE,
AFTER_DELETE,
Expand Down Expand Up @@ -77,7 +76,7 @@ class Environment(
project = models.ForeignKey(
"projects.Project",
related_name="environments",
help_text=_(
help_text=(
"Changing the project selected will remove all previous Feature States for"
" the previously associated projects Features that are related to this"
" Environment. New default Feature States will be created for the new"
Expand Down
11 changes: 5 additions & 6 deletions api/environments/urls.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from django.conf.urls import include, url
from django.urls import path
from django.urls import include, path, re_path
from rest_framework_nested import routers

from edge_api.identities.views import (
Expand Down Expand Up @@ -129,10 +128,10 @@
app_name = "environments"

urlpatterns = [
url(r"^", include(router.urls)),
url(r"^", include(environments_router.urls)),
url(r"^", include(identity_router.urls)),
url(r"^", include(edge_identity_router.urls)),
re_path(r"^", include(router.urls)),
re_path(r"^", include(environments_router.urls)),
re_path(r"^", include(identity_router.urls)),
re_path(r"^", include(edge_identity_router.urls)),
path(
"environments/<str:environment_api_key>/edge-identities-featurestates",
EdgeIdentityWithIdentifierFeatureStateView.as_view(),
Expand Down
5 changes: 2 additions & 3 deletions api/features/feature_external_resources/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from dataclasses import asdict

from django.db import models
from django.utils.translation import gettext_lazy as _
from django_lifecycle import (
AFTER_SAVE,
BEFORE_DELETE,
Expand All @@ -22,8 +21,8 @@
class FeatureExternalResource(LifecycleModelMixin, models.Model):
class ResourceType(models.TextChoices):
# GitHub external resource types
GITHUB_ISSUE = "GITHUB_ISSUE", _("GitHub Issue")
GITHUB_PR = "GITHUB_PR", _("GitHub PR")
GITHUB_ISSUE = "GITHUB_ISSUE", "GitHub Issue"
GITHUB_PR = "GITHUB_PR", "GitHub PR"

url = models.URLField()
type = models.CharField(max_length=20, choices=ResourceType.choices)
Expand Down
3 changes: 1 addition & 2 deletions api/features/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from django.db import models
from django.db.models import Max, Q, QuerySet
from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
from django_lifecycle import (
AFTER_CREATE,
AFTER_SAVE,
Expand Down Expand Up @@ -99,7 +98,7 @@ class Feature(
project = models.ForeignKey(
Project,
related_name="features",
help_text=_(
help_text=(
"Changing the project selected will remove previous Feature States for the previously "
"associated projects Environments that are related to this Feature. New default "
"Feature States will be created for the new selected projects Environments for this "
Expand Down
19 changes: 9 additions & 10 deletions api/organisations/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
get_usage_data_view,
)
from django.conf import settings
from django.conf.urls import include, url
from django.urls import path
from django.urls import include, path, re_path
from rest_framework_nested import routers

from api_keys.views import MasterAPIKeyViewSet
Expand Down Expand Up @@ -97,9 +96,9 @@


urlpatterns = [
url(r"^", include(router.urls)),
url(r"^", include(organisations_router.urls)),
url(r"^", include(nested_github_router.urls)),
re_path(r"^", include(router.urls)),
re_path(r"^", include(organisations_router.urls)),
re_path(r"^", include(nested_github_router.urls)),
path(
"<int:organisation_pk>/usage-data/",
get_usage_data_view,
Expand Down Expand Up @@ -211,10 +210,10 @@
)
urlpatterns.extend(
[
url(r"^", include(organisations_router.urls)),
url(r"^", include(nested_roles_router.urls)),
url(r"^", include(nested_user_roles_routes.urls)),
url(r"^", include(nested_api_key_roles_routes.urls)),
url(r"^", include(nested_group_roles_routes.urls)),
re_path(r"^", include(organisations_router.urls)),
re_path(r"^", include(nested_roles_router.urls)),
re_path(r"^", include(nested_user_roles_routes.urls)),
re_path(r"^", include(nested_api_key_roles_routes.urls)),
re_path(r"^", include(nested_group_roles_routes.urls)),
]
)
9 changes: 4 additions & 5 deletions api/projects/urls.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from django.conf.urls import include, url
from django.urls import path
from django.urls import include, path, re_path
from rest_framework_nested import routers

from audit.views import ProjectAuditLogViewSet
Expand Down Expand Up @@ -78,9 +77,9 @@
app_name = "projects"

urlpatterns = [
url(r"^", include(router.urls)),
url(r"^", include(projects_router.urls)),
url(r"^", include(nested_features_router.urls)),
re_path(r"^", include(router.urls)),
re_path(r"^", include(projects_router.urls)),
re_path(r"^", include(nested_features_router.urls)),
path(
"<int:project_pk>/all-user-permissions/<int:user_pk>/",
get_user_project_permissions,
Expand Down
5 changes: 2 additions & 3 deletions api/users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from django.db import models
from django.db.models import Count, QuerySet
from django.utils import timezone
from django.utils.translation import gettext_lazy as _
from django_lifecycle import AFTER_CREATE, LifecycleModel, hook

from integrations.lead_tracking.hubspot.tasks import (
Expand Down Expand Up @@ -101,8 +100,8 @@ class FFAdminUser(LifecycleModel, AbstractUser):
email = models.EmailField(unique=True, null=False)
objects = UserManager()
username = models.CharField(unique=True, max_length=150, null=True, blank=True)
first_name = models.CharField(_("first name"), max_length=30)
last_name = models.CharField(_("last name"), max_length=150)
first_name = models.CharField("first name", max_length=30)
last_name = models.CharField("last name", max_length=150)
google_user_id = models.CharField(max_length=50, null=True, blank=True)
github_user_id = models.CharField(max_length=50, null=True, blank=True)
marketing_consent_given = models.BooleanField(
Expand Down
7 changes: 3 additions & 4 deletions api/users/urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from django.conf import settings
from django.conf.urls import url
from django.urls import path
from django.urls import path, re_path

from organisations.invites.views import (
join_organisation_from_email,
Expand All @@ -23,5 +22,5 @@
),
]

if settings.ALLOW_ADMIN_INITIATION_VIA_URL:
urlpatterns.insert(0, url(r"^init/", AdminInitView.as_view()))
if settings.ALLOW_ADMIN_INITIATION_VIA_URL: # pragme: no cover
urlpatterns.insert(0, re_path(r"^init/", AdminInitView.as_view()))

0 comments on commit e613eec

Please sign in to comment.