Skip to content

Commit

Permalink
feat: Support LinkFormField of djangocms-link 5+ (#241)
Browse files Browse the repository at this point in the history
  • Loading branch information
fsbraun authored Nov 20, 2024
1 parent de6e566 commit 1d6a629
Show file tree
Hide file tree
Showing 80 changed files with 828 additions and 1,390 deletions.
20 changes: 0 additions & 20 deletions .coveragerc

This file was deleted.

7 changes: 0 additions & 7 deletions .djlint_rules.yaml

This file was deleted.

6 changes: 4 additions & 2 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Generate Report
- name: Intall dependencies
run: |
pip install -r tests/requirements/${{ matrix.requirements-file }}
coverage run run_tests.py
- name: Run coverage
run: |
coverage run -m pytest
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v5
25 changes: 0 additions & 25 deletions .github/workflows/lint.yml

This file was deleted.

18 changes: 10 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,27 @@ repos:
rev: v3.19.0
hooks:
- id: pyupgrade
args: ["--py37-plus"]
args: ["--py39-plus"]

- repo: https://github.com/adamchainz/django-upgrade
rev: "1.22.1"
hooks:
- id: django-upgrade
args: [--target-version, "2.2"]
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
name: isort (python)
args: [--target-version, "4.2"]

- repo: https://github.com/PyCQA/flake8
rev: 7.1.1
hooks:
- id: flake8
additional_dependencies:
- flake8-pyproject
- flake8-bugbear
- flake8-builtins
- flake8-django
- flake8-length
- flake8-logging-format
- flake8-spellcheck

- repo: https://github.com/tox-dev/pyproject-fmt
rev: v2.5.0
hooks:
- id: pyproject-fmt
8 changes: 4 additions & 4 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Changelog
* feat: Add float option for images by @fsbraun in https://github.com/django-cms/djangocms-frontend/pull/162
* feat: Add drag'n'drop support for djangocms-text-ckeditor by @fsbraun in https://github.com/django-cms/djangocms-frontend/pull/165
* fix: Ckeditor does not show icons for editing by @fsbraun in https://github.com/django-cms/djangocms-frontend/pull/163
* fix: Replace ``stylesSet`` setting in docs with ``customConfig` for icons in ckeditor by @fsbraun in https://github.com/django-cms/djangocms-frontend/pull/164
* fix: Replace ``stylesSet`` setting in docs with ``customConfig`` for icons in ckeditor by @fsbraun in https://github.com/django-cms/djangocms-frontend/pull/164
* ci: pre-commit autoupdate by @pre-commit-ci in https://github.com/django-cms/djangocms-frontend/pull/161


Expand All @@ -106,15 +106,15 @@ Changelog
==================

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

1.1.5 (2023-07-14)
==================

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

1.1.4 (2023-05-28)
==================
Expand Down
67 changes: 30 additions & 37 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,33 @@

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

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

.. image:: preview.png

Key features
============

- **Easy to implement re-usable frontend custom components**, which in the
simplest case consist of a template and declarative sort of form class.

- Support of `Bootstrap 5 <https://getbootstrap.com>`_, django CMS 3.8+
and django CMS 4.
and django CMS 4 out of the box.

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

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

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

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

- A management command to **migrate from djangocms-bootstrap4**. This
command automatically migrates all ``djangocms-bootstrap4`` plugins to
``djangocms-frontend``.


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

The link plugin has been rewritten to not only allow internal links to other
CMS pages, but also to other django models such as, e.g., posts of
`djangocms-blog <https://github.com/nephila/djangocms-blog>`_.

The plugins are designed to be re-usable as UI components in your
project, e.g. in a custom app, giving your whole project a more
consistent user experience.
Expand Down Expand Up @@ -98,8 +94,7 @@ file for additional dependencies:
- django-cms, version 3.7 or later
- django-filer, version 1.7 or later
- djangocms-attributes-field, version 1.0 or later
- djangocms-text-ckeditor, version 3.1 or later
- django-select2
- djangocms-text
- django-entangled

Make sure `django Filer
Expand All @@ -121,23 +116,22 @@ For a manual install:
'easy_thumbnails',
'djangocms_frontend',
'djangocms_frontend.contrib.accordion',
'djangocms_frontend.contrib.alert',
'djangocms_frontend.contrib.badge',
'djangocms_frontend.contrib.card',
'djangocms_frontend.contrib.carousel',
'djangocms_frontend.contrib.collapse',
'djangocms_frontend.contrib.component',
'djangocms_frontend.contrib.content',
'djangocms_frontend.contrib.grid',
'djangocms_frontend.contrib.icon',
'djangocms_frontend.contrib.image',
'djangocms_frontend.contrib.jumbotron',
'djangocms_frontend.contrib.link',
'djangocms_frontend.contrib.listgroup',
'djangocms_frontend.contrib.media',
'djangocms_frontend.contrib.tabs',
'djangocms_frontend.contrib.utilities',
'djangocms_frontend.contrib.accordion', # optional
'djangocms_frontend.contrib.alert', # optional
'djangocms_frontend.contrib.badge', # optional
'djangocms_frontend.contrib.card', # optional
'djangocms_frontend.contrib.carousel', # optional
'djangocms_frontend.contrib.collapse', # optional
'djangocms_frontend.contrib.content', # optional
'djangocms_frontend.contrib.grid', # optional
'djangocms_frontend.contrib.icon', # optional
'djangocms_frontend.contrib.image', # optional
'djangocms_frontend.contrib.jumbotron', # optional
'djangocms_frontend.contrib.link', # optional
'djangocms_frontend.contrib.listgroup', # optional
'djangocms_frontend.contrib.media', # optional
'djangocms_frontend.contrib.tabs', # optional
'djangocms_frontend.contrib.utilities', # optional
- run ``python manage.py migrate``

Expand All @@ -153,8 +147,7 @@ install separately or by adding an option:
Documentation
=============

See readthedocs for the `documentation
<https://djangocms-frontend.readthedocs.io>`_.
See readthedocs for the `documentation <https://djangocms-frontend.readthedocs.io>`_.

License
=======
Expand Down
16 changes: 8 additions & 8 deletions run_tests.py → conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
from django.test.utils import get_runner


def run(argv=None):
if argv is None:
argv = ["tests"]
tests = argv[1:] if len(argv) > 1 else ["tests"]
def pytest_configure():
os.environ["DJANGO_SETTINGS_MODULE"] = "tests.test_settings"
django.setup()


if __name__ == "__main__":
pytest_configure()

argv = ["tests"] if sys.argv is None else sys.argv
tests = argv[1:] if len(argv) > 1 else ["tests"]
TestRunner = get_runner(settings)
test_runner = TestRunner()
failures = test_runner.run_tests(tests)
sys.exit(bool(failures))


if __name__ == "__main__":
run(sys.argv)
2 changes: 1 addition & 1 deletion djangocms_frontend/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
13. Github actions will publish the new package to pypi
"""

__version__ = "2.0.0a"
__version__ = "2.0.0a1"
63 changes: 60 additions & 3 deletions djangocms_frontend/apps.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,68 @@
from django import apps
from django.core import checks


class DjangocmsFrontendConfig(apps.AppConfig):
name = "djangocms_frontend"
verbose_name = "DjangoCMS Frontend"
verbose_name = "django CMS Frontend"

def ready(self):
from .component_pool import setup
from . import plugin_tag

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


def check_settings(*args, **kwargs): # pragma: no cover
from django.conf import settings

warnings = []

if hasattr(settings, "DJANGOCMS_FRONTEND_MINIMUM_INPUT_LENGTH"):
warnings.append(
checks.Warning(
"The DJANGOCMS_FRONTEND_MINIMUM_INPUT_LENGTH setting was removed in djangocms-frontend 2.",
"Use DJANGOCMS_LINK_MINIMUM_INPUT_LENGTH instead.",
id="djangocms_frontend.W001",
obj="settings.DJANGOCMS_FRONTEND_MINIMUM_INPUT_LENGTH",
)
)
if hasattr(settings, "DJANGOCMS_FRONTEND_LINK_MODELS"):
warnings.append(
checks.Warning(
"The DJANGOCMS_FRONTEND_LINK_MODELS setting was removed in djangocms-frontend 2. "
"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


def check_installed_apps(*args, **kwargs): # pragma: no cover
from django.conf import settings

errors = []
link_contrib_apps = [
"djangocms_frontend.contrib.carousel",
"djangocms_frontend.contrib.image",
"djangocms_frontend.contrib.link",
]
link_apps_used = [app for app in link_contrib_apps if app in settings.INSTALLED_APPS]
if link_apps_used:
if "djangocms_link" not in settings.INSTALLED_APPS:
errors.append(
checks.Error(
"djangocms-frontend requires djangocms-link to be installed for {}.".format(
", ".join(link_apps_used)
),
"Add 'djangocms_link' to your INSTALLED_APPS setting or remove all of the above apps.",
id="djangocms_frontend.E001",
obj="settings.INSTALLED_APPS",
)
)
return errors
Loading

0 comments on commit 1d6a629

Please sign in to comment.