Skip to content

Commit

Permalink
add: check to see if specified pulic/whitelisted urls are actually av…
Browse files Browse the repository at this point in the history
…ailable in the project
  • Loading branch information
saemideluxe committed Nov 9, 2023
1 parent 1a7d759 commit 251bebe
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions basxbread/apps.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.apps import AppConfig
from django.contrib.messages.constants import DEFAULT_TAGS
from django.core.checks import Error, register
from django.utils.translation import gettext as _


Expand All @@ -13,6 +14,24 @@ def ready(self):
patch_django_filters_verbose_name_func()


@register()
def whitelisted_urls_check(app_configs, **kwargs):
from django.conf import settings
from django.urls import get_resolver

errors = []
for url in getattr(settings, "PUBLIC_URLS", []):
if url not in get_resolver().reverse_dict:
errors.append(
Error(
"Whitelisted URL not found",
obj=url,
id="basxbread.E001",
)
)
return errors


def patch_django_filters_verbose_name_func():
# django filters verbose_field_name function is not great at using the
# verbose names on related fields, patching this here
Expand Down

0 comments on commit 251bebe

Please sign in to comment.