Skip to content

Commit 1d6a629

Browse files
authored
feat: Support LinkFormField of djangocms-link 5+ (#241)
1 parent de6e566 commit 1d6a629

File tree

80 files changed

+828
-1390
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+828
-1390
lines changed

.coveragerc

Lines changed: 0 additions & 20 deletions
This file was deleted.

.djlint_rules.yaml

Lines changed: 0 additions & 7 deletions
This file was deleted.

.github/workflows/codecov.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@ jobs:
3232
uses: actions/setup-python@v5
3333
with:
3434
python-version: ${{ matrix.python-version }}
35-
- name: Generate Report
35+
- name: Intall dependencies
3636
run: |
3737
pip install -r tests/requirements/${{ matrix.requirements-file }}
38-
coverage run run_tests.py
38+
- name: Run coverage
39+
run: |
40+
coverage run -m pytest
3941
- name: Upload Coverage to Codecov
4042
uses: codecov/codecov-action@v5

.github/workflows/lint.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,27 @@ repos:
1212
rev: v3.19.0
1313
hooks:
1414
- id: pyupgrade
15-
args: ["--py37-plus"]
15+
args: ["--py39-plus"]
16+
1617
- repo: https://github.com/adamchainz/django-upgrade
1718
rev: "1.22.1"
1819
hooks:
1920
- id: django-upgrade
20-
args: [--target-version, "2.2"]
21-
- repo: https://github.com/pycqa/isort
22-
rev: 5.13.2
23-
hooks:
24-
- id: isort
25-
name: isort (python)
21+
args: [--target-version, "4.2"]
22+
2623
- repo: https://github.com/PyCQA/flake8
2724
rev: 7.1.1
2825
hooks:
2926
- id: flake8
3027
additional_dependencies:
28+
- flake8-pyproject
3129
- flake8-bugbear
3230
- flake8-builtins
3331
- flake8-django
3432
- flake8-length
3533
- flake8-logging-format
36-
- flake8-spellcheck
34+
35+
- repo: https://github.com/tox-dev/pyproject-fmt
36+
rev: v2.5.0
37+
hooks:
38+
- id: pyproject-fmt

CHANGELOG.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ Changelog
8282
* feat: Add float option for images by @fsbraun in https://github.com/django-cms/djangocms-frontend/pull/162
8383
* feat: Add drag'n'drop support for djangocms-text-ckeditor by @fsbraun in https://github.com/django-cms/djangocms-frontend/pull/165
8484
* fix: Ckeditor does not show icons for editing by @fsbraun in https://github.com/django-cms/djangocms-frontend/pull/163
85-
* fix: Replace ``stylesSet`` setting in docs with ``customConfig` for icons in ckeditor by @fsbraun in https://github.com/django-cms/djangocms-frontend/pull/164
85+
* fix: Replace ``stylesSet`` setting in docs with ``customConfig`` for icons in ckeditor by @fsbraun in https://github.com/django-cms/djangocms-frontend/pull/164
8686
* ci: pre-commit autoupdate by @pre-commit-ci in https://github.com/django-cms/djangocms-frontend/pull/161
8787

8888

@@ -106,15 +106,15 @@ Changelog
106106
==================
107107

108108
* Fix incomplete migration of code plugins from djangocms-bootstrap4
109-
* Add compiled French locale (*.mo)
109+
* Add compiled French locale (\*.mo)
110110
* Add partial Dutch locale
111111

112112
1.1.5 (2023-07-14)
113113
==================
114114

115115
* Fix bug where url for link select2 field was lost after app hook reload (#135)
116-
* Use `bg-body` class on Bootstrap 5's tab navigation to support color modes (#138)
117-
* Fix styling of icon buttons for better usager with plain django admin style (#141)
116+
* Use ``bg-body`` class on Bootstrap 5's tab navigation to support color modes (#138)
117+
* Fix styling of icon buttons for better usage with plain django admin style (#141)
118118

119119
1.1.4 (2023-05-28)
120120
==================

README.rst

Lines changed: 30 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,33 @@
44

55
|pypi| |docs| |coverage| |python| |django| |djangocms| |djangocms4|
66

7-
**django CMS Frontend** is a plugin bundle which builds on and improves
7+
**django CMS Frontend** is a plugin bundle which originally built on and improved
88
the architecture of `djangocms-bootstrap4 <https://github.com/django-cms/djangocms-bootstrap4>`_.
9-
Its objective is to provide a set of popular frontend components independent of the
10-
currently used frontend framework such as Bootstrap, or its specific version.
9+
Its objective is to provide a toolset to quickly create re-usable frontend
10+
components and comes preloaded with a set of popular frontend components
11+
independent of the currently used frontend framework such as Bootstrap, or
12+
its specific version.
1113

1214
.. image:: preview.png
1315

1416
Key features
1517
============
1618

19+
- **Easy to implement re-usable frontend custom components**, which in the
20+
simplest case consist of a template and declarative sort of form class.
21+
1722
- Support of `Bootstrap 5 <https://getbootstrap.com>`_, django CMS 3.8+
18-
and django CMS 4.
23+
and django CMS 4 out of the box.
1924

2025
- **Separation of plugins from css framework**, i.e. no need to
2126
rebuild you site's plugin tree if css framework is changed in the
2227
future, e.g. from Bootstrap 5 to a future version.
2328

24-
- **New link plugin** allowing to link to internal pages provided by
25-
other applications, such as `djangocms-blog
29+
- Leverage of new **djangocms-link features** allowing to link to internal pages
30+
provided by other applications, such as `djangocms-blog
2631
<https://github.com/nephila/djangocms-blog>`_.
2732

28-
- **Nice and well-arranged admin frontend** of `djangocms-bootstrap4
29-
<https://github.com/django-cms/djangocms-bootstrap4>`_
33+
- **Nice and well-arranged admin frontend** of djangocms-bootstrap4
3034

3135
- **Extensible** within the project and with separate project (e.g. a
3236
theme app). Create your own components with a few lines of code only.
@@ -35,10 +39,6 @@ Key features
3539
(e.g. in a custom app) giving your whole project a more consistent
3640
user experience.
3741

38-
- A management command to **migrate from djangocms-bootstrap4**. This
39-
command automatically migrates all ``djangocms-bootstrap4`` plugins to
40-
``djangocms-frontend``.
41-
4242

4343
Description
4444
===========
@@ -55,10 +55,6 @@ Instead all design parameters are stored in a common JSON field and
5555
future releases of improved frontend features will not require to
5656
rebuild your full plugin tree.
5757

58-
The link plugin has been rewritten to not only allow internal links to other
59-
CMS pages, but also to other django models such as, e.g., posts of
60-
`djangocms-blog <https://github.com/nephila/djangocms-blog>`_.
61-
6258
The plugins are designed to be re-usable as UI components in your
6359
project, e.g. in a custom app, giving your whole project a more
6460
consistent user experience.
@@ -98,8 +94,7 @@ file for additional dependencies:
9894
- django-cms, version 3.7 or later
9995
- django-filer, version 1.7 or later
10096
- djangocms-attributes-field, version 1.0 or later
101-
- djangocms-text-ckeditor, version 3.1 or later
102-
- django-select2
97+
- djangocms-text
10398
- django-entangled
10499

105100
Make sure `django Filer
@@ -121,23 +116,22 @@ For a manual install:
121116
122117
'easy_thumbnails',
123118
'djangocms_frontend',
124-
'djangocms_frontend.contrib.accordion',
125-
'djangocms_frontend.contrib.alert',
126-
'djangocms_frontend.contrib.badge',
127-
'djangocms_frontend.contrib.card',
128-
'djangocms_frontend.contrib.carousel',
129-
'djangocms_frontend.contrib.collapse',
130-
'djangocms_frontend.contrib.component',
131-
'djangocms_frontend.contrib.content',
132-
'djangocms_frontend.contrib.grid',
133-
'djangocms_frontend.contrib.icon',
134-
'djangocms_frontend.contrib.image',
135-
'djangocms_frontend.contrib.jumbotron',
136-
'djangocms_frontend.contrib.link',
137-
'djangocms_frontend.contrib.listgroup',
138-
'djangocms_frontend.contrib.media',
139-
'djangocms_frontend.contrib.tabs',
140-
'djangocms_frontend.contrib.utilities',
119+
'djangocms_frontend.contrib.accordion', # optional
120+
'djangocms_frontend.contrib.alert', # optional
121+
'djangocms_frontend.contrib.badge', # optional
122+
'djangocms_frontend.contrib.card', # optional
123+
'djangocms_frontend.contrib.carousel', # optional
124+
'djangocms_frontend.contrib.collapse', # optional
125+
'djangocms_frontend.contrib.content', # optional
126+
'djangocms_frontend.contrib.grid', # optional
127+
'djangocms_frontend.contrib.icon', # optional
128+
'djangocms_frontend.contrib.image', # optional
129+
'djangocms_frontend.contrib.jumbotron', # optional
130+
'djangocms_frontend.contrib.link', # optional
131+
'djangocms_frontend.contrib.listgroup', # optional
132+
'djangocms_frontend.contrib.media', # optional
133+
'djangocms_frontend.contrib.tabs', # optional
134+
'djangocms_frontend.contrib.utilities', # optional
141135
142136
- run ``python manage.py migrate``
143137

@@ -153,8 +147,7 @@ install separately or by adding an option:
153147
Documentation
154148
=============
155149

156-
See readthedocs for the `documentation
157-
<https://djangocms-frontend.readthedocs.io>`_.
150+
See readthedocs for the `documentation <https://djangocms-frontend.readthedocs.io>`_.
158151

159152
License
160153
=======

run_tests.py renamed to conftest.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@
77
from django.test.utils import get_runner
88

99

10-
def run(argv=None):
11-
if argv is None:
12-
argv = ["tests"]
13-
tests = argv[1:] if len(argv) > 1 else ["tests"]
10+
def pytest_configure():
1411
os.environ["DJANGO_SETTINGS_MODULE"] = "tests.test_settings"
1512
django.setup()
13+
14+
15+
if __name__ == "__main__":
16+
pytest_configure()
17+
18+
argv = ["tests"] if sys.argv is None else sys.argv
19+
tests = argv[1:] if len(argv) > 1 else ["tests"]
1620
TestRunner = get_runner(settings)
1721
test_runner = TestRunner()
1822
failures = test_runner.run_tests(tests)
1923
sys.exit(bool(failures))
20-
21-
22-
if __name__ == "__main__":
23-
run(sys.argv)

djangocms_frontend/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@
1919
13. Github actions will publish the new package to pypi
2020
"""
2121

22-
__version__ = "2.0.0a"
22+
__version__ = "2.0.0a1"

djangocms_frontend/apps.py

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,68 @@
11
from django import apps
2+
from django.core import checks
23

34

45
class DjangocmsFrontendConfig(apps.AppConfig):
56
name = "djangocms_frontend"
6-
verbose_name = "DjangoCMS Frontend"
7+
verbose_name = "django CMS Frontend"
78

89
def ready(self):
9-
from .component_pool import setup
10+
from . import plugin_tag
1011

11-
setup()
12+
plugin_tag.setup()
13+
checks.register(check_settings)
14+
checks.register(check_installed_apps)
15+
16+
17+
def check_settings(*args, **kwargs): # pragma: no cover
18+
from django.conf import settings
19+
20+
warnings = []
21+
22+
if hasattr(settings, "DJANGOCMS_FRONTEND_MINIMUM_INPUT_LENGTH"):
23+
warnings.append(
24+
checks.Warning(
25+
"The DJANGOCMS_FRONTEND_MINIMUM_INPUT_LENGTH setting was removed in djangocms-frontend 2.",
26+
"Use DJANGOCMS_LINK_MINIMUM_INPUT_LENGTH instead.",
27+
id="djangocms_frontend.W001",
28+
obj="settings.DJANGOCMS_FRONTEND_MINIMUM_INPUT_LENGTH",
29+
)
30+
)
31+
if hasattr(settings, "DJANGOCMS_FRONTEND_LINK_MODELS"):
32+
warnings.append(
33+
checks.Warning(
34+
"The DJANGOCMS_FRONTEND_LINK_MODELS setting was removed in djangocms-frontend 2. "
35+
"djangocms-frontend 2 uses linkable models from djangocms-link. See "
36+
"https://github.com/django-cms/djangocms-link#django-cms-link for more info.",
37+
"This message disappears after removing the DJANGOCMS_FRONTEND_LINK_MODELS from your "
38+
"project's settings.\n",
39+
id="djangocms_frontend.W002",
40+
obj="settings.DJANGOCMS_FRONTEND_LINK_MODELS",
41+
)
42+
)
43+
return warnings
44+
45+
46+
def check_installed_apps(*args, **kwargs): # pragma: no cover
47+
from django.conf import settings
48+
49+
errors = []
50+
link_contrib_apps = [
51+
"djangocms_frontend.contrib.carousel",
52+
"djangocms_frontend.contrib.image",
53+
"djangocms_frontend.contrib.link",
54+
]
55+
link_apps_used = [app for app in link_contrib_apps if app in settings.INSTALLED_APPS]
56+
if link_apps_used:
57+
if "djangocms_link" not in settings.INSTALLED_APPS:
58+
errors.append(
59+
checks.Error(
60+
"djangocms-frontend requires djangocms-link to be installed for {}.".format(
61+
", ".join(link_apps_used)
62+
),
63+
"Add 'djangocms_link' to your INSTALLED_APPS setting or remove all of the above apps.",
64+
id="djangocms_frontend.E001",
65+
obj="settings.INSTALLED_APPS",
66+
)
67+
)
68+
return errors

0 commit comments

Comments
 (0)