Skip to content

Commit

Permalink
feat: Check for link configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
fsbraun committed Nov 20, 2024
1 parent b6f1470 commit 5776cd1
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 28 deletions.
63 changes: 47 additions & 16 deletions djangocms_frontend/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def ready(self):
from . import plugin_tag

checks.register(check_settings)
checks.register(check_installed_apps)
plugin_tag.setup()


Expand All @@ -19,21 +20,51 @@ def check_settings(*args, **kwargs):
warnings = []

Check warning on line 20 in djangocms_frontend/apps.py

View check run for this annotation

Codecov / codecov/patch

djangocms_frontend/apps.py#L20

Added line #L20 was not covered by tests

if hasattr(settings, "DJANGOCMS_FRONTEND_MINIMUM_INPUT_LENGTH"): # pragma: no cover
warnings.append(checks.Warning(
"The DJANGOCMS_FRONTEND_MINIMUM_INPUT_LENGTH setting was removed in djangocms-frontend 2.\n"
"Use DJANGOCMS_LINK_MINIMUM_INPUT_LENGTH instead.",
"This message disappears after removing the DJANGOCMS_FRONTEND_MINIMUM_INPUT_LENGTH from your project's "
"settings.\n",
id="djangocms_frontend.W001",
obj="settings.DJANGOCMS_FRONTEND_MINIMUM_INPUT_LENGTH",
))
warnings.append(
checks.Warning(
"The DJANGOCMS_FRONTEND_MINIMUM_INPUT_LENGTH setting was removed in djangocms-frontend 2.\n"
"Use DJANGOCMS_LINK_MINIMUM_INPUT_LENGTH instead.",
"This message disappears after removing the DJANGOCMS_FRONTEND_MINIMUM_INPUT_LENGTH from "
"your project's settings.\n",
id="djangocms_frontend.W001",
obj="settings.DJANGOCMS_FRONTEND_MINIMUM_INPUT_LENGTH",
)
)
if hasattr(settings, "DJANGOCMS_FRONTEND_LINK_MODELS"): # pragma: no cover
warnings.append(checks.Warning(
"The DJANGOCMS_FRONTEND_LINK_MODELS setting was removed in djangocms-frontend 2.\n"
"djangocms-frontend 2 uses linkable models from djangocms-link. See "
"https://github.com/django-cms/djangocms-link#django-cms-link for more info.",
"This message disappears after removing the DJANGOCMS_FRONTEND_LINK_MODELS from your project's settings.\n",
id="djangocms_frontend.W002",
obj="settings.DJANGOCMS_FRONTEND_LINK_MODELS",
))
warnings.append(
checks.Warning(
"The DJANGOCMS_FRONTEND_LINK_MODELS setting was removed in djangocms-frontend 2.\n"
"djangocms-frontend 2 uses linkable models from djangocms-link. See "
"https://github.com/django-cms/djangocms-link#django-cms-link for more info.",
"This message disappears after removing the DJANGOCMS_FRONTEND_LINK_MODELS from your "
"project's settings.\n",
id="djangocms_frontend.W002",
obj="settings.DJANGOCMS_FRONTEND_LINK_MODELS",
)
)
return warnings

Check warning on line 45 in djangocms_frontend/apps.py

View check run for this annotation

Codecov / codecov/patch

djangocms_frontend/apps.py#L45

Added line #L45 was not covered by tests


def check_installed_apps(app_configs, **kwargs):
from django.conf import settings

Check warning on line 49 in djangocms_frontend/apps.py

View check run for this annotation

Codecov / codecov/patch

djangocms_frontend/apps.py#L49

Added line #L49 was not covered by tests

errors = []
link_contrib_apps = [

Check warning on line 52 in djangocms_frontend/apps.py

View check run for this annotation

Codecov / codecov/patch

djangocms_frontend/apps.py#L51-L52

Added lines #L51 - L52 were not covered by tests
"djangocms_frontend.contrib.carousel",
"djangocms_frontend.contrib.image",
"djangocms_frontend.contrib.link",
]

if any(app in settings.INSTALLED_APPS for app in link_contrib_apps):

Check warning on line 58 in djangocms_frontend/apps.py

View check run for this annotation

Codecov / codecov/patch

djangocms_frontend/apps.py#L58

Added line #L58 was not covered by tests
if "djangocms_link" not in settings.INSTALLED_APPS: # pragma: no cover
errors.append(
checks.Error(
"djangocms-frontend requires djangocms-link to be installed for the following plugins: {}.\n"
"Add 'djangocms_link' to your INSTALLED_APPS setting or remove all of the above apps.".format(
", ".join(link_contrib_apps)
),
id="djangocms_frontend.E001",
obj="settings.INSTALLED_APPS",
)
)
return errors

Check warning on line 70 in djangocms_frontend/apps.py

View check run for this annotation

Codecov / codecov/patch

djangocms_frontend/apps.py#L70

Added line #L70 was not covered by tests
2 changes: 1 addition & 1 deletion djangocms_frontend/static/djangocms_frontend/css/base.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion private/sass/components/_tabs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
}

ul.nav {
&:has(> li ~ div) {
&:not(:has(> li:nth-child(2))) {
// Hide single tab
display: none;
}
Expand Down
20 changes: 10 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[tool.black]
exclude = [
".git",
".hg",
".tox",
"venv",
".venv",
"_build",
"build",
"dist",
]
exclude = '''
.git
.hg
.tox
venv
.venv
_build
build
dist
'''

[tool.ruff]
line-length = 119
Expand Down

0 comments on commit 5776cd1

Please sign in to comment.