8000 chore: merge develop-4 into release/4.1.x by fsbraun · Pull Request #7886 · django-cms/django-cms · GitHub
[go: up one dir, main page]

Skip to content

chore: merge develop-4 into release/4.1.x #7886

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 71 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
fdc3639
chore: Merge back `release/4.1.x` into `develop-4` (#7731)
fsbraun Jan 5, 2024
e0c7550
fix issue #7745 (#7747)
jrief Jan 10, 2024
885ee98
docs: Update how-to use placeholder in custom models (#7742)
fsbraun Jan 10, 2024
df0831d
adopt <form id="…"> to proper model (#7753)
jrief Jan 10, 2024
082214b
fix: Incorrect commands to migrate database in docs (#7754)
sakhawy Jan 10, 2024
10e9b53
fix: Replace the VCS pip installs with release name in docs (#7755)
sakhawy Jan 10, 2024
b1bca46
build(deps): bump actions/setup-python from 2 to 5 (#7760)
dependabot[bot] Jan 12, 2024
dc4fab1
build(deps): bump jinja2 from 3.1.2 to 3.1.3 in /docs (#7761)
dependabot[bot] Jan 13, 2024
074dba2
build(deps): bump github/codeql-action from 2 to 3 (#7759)
dependabot[bot] Jan 13, 2024
8000
4538b68
build(deps): bump actions/checkout from 3 to 4 (#7758)
dependabot[bot] Jan 13, 2024
31c458f
build(deps): bump amannn/action-semantic-pull-request from 4 to 5 (#7…
dependabot[bot] Jan 13, 2024
3ba3da1
build(deps): bump actions/github-script from 5 to 7 (#7756)
dependabot[bot] Jan 13, 2024
68749cb
fix: make messages readable in dark mode, let user close long message…
fsbraun Jan 14, 2024
c20b042
build(deps): bump actions/setup-node from 3 to 4 (#7764)
dependabot[bot] Jan 15, 2024
cd6df84
fix: editing of apphooked CMS pages without apphook landing page (#7766)
Chilipp Jan 18, 2024
0f37d79
chore: Update github issue and PR templates (#7767)
fsbraun Jan 19, 2024
5981dfc
Issue 7763 is fixed (#7771)
erkesado Jan 21, 2024
23d70a9
build(deps): bump actions/cache from 3 to 4 (#7775)
dependabot[bot] Jan 22, 2024
ed7e206
build(deps): bump django from 3.2.16 to 3.2.23 in /docs (#7776)
dependabot[bot] Jan 23, 2024
f290e3d
fix: Redirect user to edit url after a successful page creation (#7772)
sakhawy Jan 26, 2024
ce8d5d5
fix: return _handle_no_page when page is None (#7786)
sakhawy Jan 27, 2024
5f3f0c9
chore: Update PR lint action (#7790)
marksweb Jan 28, 2024
9074f83
ci: Adjust CI triggers to mostly PR runs (#7791)
marksweb Jan 28, 2024
e1ba77a
ci: Added pre-commit including ruff linting & formatting (#7788)
marksweb Jan 29, 2024
ad02c75
docs: Update dev policies (#7793)
marksweb Jan 29, 2024
121ff74
fix versioning links (#7795)
Aiden-RC Jan 29, 2024
311af6c
feat: Added new contributor message based on django's own version (#7…
marksweb Jan 30, 2024
4fbd4dc
ci: Update new_contributor_pr.yml (#7803)
Aiden-RC Jan 31, 2024
9e56597
ci: Added ruff format rules (#7800)
marksweb Feb 2, 2024
26b081a
fix: Port forward #7070 - faster DOM update after editing (#7787)
fsbraun Feb 4, 2024
545ea1f
feat: add versioned deprecation warnings (#7750)
fsbraun Feb 10, 2024
2246442
ci: Fix discord notification action version (#7811)
marksweb Feb 13, 2024
8a0aa59
build(deps): bump django from 3.2.23 to 3.2.24 in /docs (#7806)
dependabot[bot] Feb 13, 2024
8c8afb0
build(deps-dev): bump ip from 1.1.5 to 1.1.9 (#7821)
dependabot[bot] Feb 21, 2024
f4c77c8
ci: Fix discord notification action inputs (#7824)
marksweb Feb 27, 2024
744f406
docs: Update to reflect new, simplified contributing process (#7827)
fsbraun Feb 28, 2024
4e085a4
Update 01-install.rst (#7823)
sparrowme Feb 28, 2024
087fa3e
fix: solved issue #7818 (#7819)
raffaellasuardini Feb 28, 2024
e264d04
fix: render content in place `redirect_on_fallback` is False (#7781)
sakhawy Feb 28, 2024
3e635d3
fix: Delete orphaned plugin management command for django CMS 4 (#7814)
fsbraun Feb 29, 2024
b0f59bb
fix: Efficient build menu for versioned and unversioned pages (#7807)
fsbraun Feb 29, 2024
08463c2
fix: 7828, try using uv as pip replacement (#7829)
Mar 5, 2024
21d6a6d
fix: Add RTL support to pagetree (#7817)
sakhawy Mar 6, 2024
d123d11
fix: Render structure view in toolbar object's language (#7846)
fsbraun Mar 21, 2024
fa7b89c
fix: `views.details` revealed existence of unpublished language (#7853)
fsbraun Mar 25, 2024
1344853
Fix documentation typo (#7860)
milosnikic Mar 28, 2024
01dc649
fix #7826
jrief Feb 28, 2024
0b43a43
fix: Redirects to newly created object (#7864)
fsbraun Apr 4, 2024
6dd06bf
build(deps): bump black from 22.12.0 to 24.3.0 in /docs (#7848)
dependabot[bot] Apr 4, 2024
3a001a2
build(deps): bump django from 3.2.24 to 3.2.25 in /docs (#7845)
dependabot[bot] Apr 4, 2024
1bd19b5
build(deps-dev): bump follow-redirects from 1.15.2 to 1.15.6 (#7843)
dependabot[bot] Apr 4, 2024
570c122
build(deps): bump axios and browser-sync (#7822)
dependabot[bot] Apr 4, 2024
1bb43c9
Create FUNDING.yml (#7852)
fsbraun Apr 5, 2024
c600897
build(deps): bump urllib3 from 1.26.12 to 1.26.18 in /docs (#7778)
dependabot[bot] Apr 5, 2024
6da9de8
Merge branch 'develop-4' of github.com:fsbraun/django-cms into develop-4
fsbraun Apr 7, 2024
92a1086
feat: Add RTL support to toolbar (#7871)
sakhawy Apr 15, 2024
12ad276
build(deps): bump sqlparse from 0.4.3 to 0.5.0 in /docs (#7874)
dependabot[bot] Apr 18, 2024
ee2f469
Merge branch 'develop-4' of github.com:fsbraun/django-cms into develop-4
fsbraun Apr 18, 2024
3fba0c8
build(deps): bump idna from 3.4 to 3.7 in /docs (#7870)
dependabot[bot] Apr 18, 2024
1854ba4
Merge branch 'develop-4' of github.com:fsbraun/django-cms into develop-4
fsbraun Apr 19, 2024
564f184
docs: Add documentation for some cms.utils.plugins functions (#7884)
fsbraun Apr 19, 2024
6b78c89
Merge branch 'release/4.1.x' into develop-4
fsbraun Apr 19, 2024
566cbf4
Merge branch 'develop-4' of github.com:fsbraun/django-cms into develop-4
fsbraun Apr 19, 2024
513318c
Fix merge errors
fsbraun Apr 19, 2024
a6511da
docs: Replace Slack with Discord (#7877)
macolo Apr 20, 2024
c436cf4
fix: some Django antipatterns (#7867)
jrief Apr 20, 2024
95e9afb
Merge branch 'django-cms:develop-4' into develop-4
fsbraun Apr 20, 2024
bef0045
feat: Add RTL support to modal header and related components (#7863)
sakhawy Apr 23, 2024
7f1ec98
Merge branch 'django-cms:develop-4' into develop-4
fsbraun Apr 23, 2024
fb30434
fix: CMS widgets need not load if they are read only (#7880)
fsbraun Apr 23, 2024
6771f8b
Merge branch 'django-cms:develop-4' into develop-4
fsbraun Apr 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
docs: Add documentation for some cms.utils.plugins functions (#7884)
* Adds reference docs to some plugin utility functions.

* add more docstrings

* Update docs
  • Loading branch information
fsbraun authored Apr 19, 2024
commit 564f1846e3bc210048337ceafc8a1baaa1cadf4c
94 changes: 91 additions & 3 deletions cms/utils/plugins.py
10000
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,28 @@ def get_plugin_model(plugin_type: str) -> CMSPlugin:


def get_plugins(request, placeholder, template, lang=None):
"""
Get a list of plugins for a placeholder in a specified template. Respects the placeholder's cache.

:param request: (HttpRequest) The HTTP request object.
:param placeholder: (Placeholder) The placeholder object for which to retrieve plugins.
:param template: (Template) The template object in which the placeholder resides (not used).
:param lang: (str, optional) The language code for localization. Defaults to None.

Returns:
list: A list of plugins for the specified placeholder in the template.

Raises:
None.

Examples::

# Get plugins for a placeholder in a template
plugins = get_plugins(request, placeholder, template)

# Get plugins for a placeholder in a template with specific language
plugins = get_plugins(request, placeholder, template, lang='en')
"""
if not placeholder:
return []
if not hasattr(placeholder, '_plugins_cache'):
Expand All @@ -42,6 +64,23 @@ def assign_plugins(request, placeholders, template=None, lang=None):
Fetch all plugins for the given ``placeholders`` and
cast them down to the concrete instances in one query
per type.

:param request: The current request.
:param placeholders: An iterable of placeholder objects.
:param template: (optional) The template object.
:param lang: (optional) The language code.

This method assigns plugins to the given placeholders. It retrieves the plugins from the database based on the
placeholders and the language. The plugins are then downcasted to their specific plugin types.

The plugins are split up by placeholder and stored in a dictionary where the key is the placeholder ID and the
value is a list of plugins.

For each placeholder, if there are plugins assigned to it, the plugins are organized as a layered tree structure.
Otherwise, an empty list is assigned.

The list of all plugins for each placeholder is stored in the `_all_plugins_cache` attribute of the placeholder,
while the list of root plugins is stored in the `_plugins_cache` attribute
"""
if not placeholders:
return
Expand Down Expand Up @@ -164,7 +203,7 @@ def copy_plugins_to_placeholder(plugins, placeholder, language=None,
#. Set the id/pk to None to it the id of the generic plugin instance above;
this will effectively change the generic plugin created above
into a concrete one
#. find the position in the new plalceholder
#. find the position in the new placeholder
#. save the concrete plugin (which creates a new plugin in the database)
#. trigger the copy relations
#. return the plugin ids
Expand Down Expand Up @@ -251,6 +290,27 @@ def copy_plugins_to_placeholder(plugins, placeholder, language=None,


def get_bound_plugins(plugins):
"""
Get the bound plugins by downcasting the plugins to their respective classes. Raises a KeyError if the plugin type
is not available.

Creates a map of plugin types and their corresponding plugin IDs for later use in downcasting.
Then, retrieves the plugin instances from the plugin model using the mapped plugin IDs.
Finally, iterates over the plugins and yields the downcasted versions if they have a valid parent.
Does not affect caching.

:param plugins: (list) List of ``CMSPlugin`` instances.

Yields:
- instance (``CMSPlugin`` sub-class): Downcasted Plugin instance.

Example::

plugins = [plugin_instance1, plugin_instance2]
for bound_plugin in get_bound_plugins(plugins):
# Do something with the bound_plugin
pass
"""
get_plugin = plugin_pool.get_plugin
plugin_types_map = defaultdict(list)
plugin_ids = []
Expand Down Expand Up @@ -281,6 +341,21 @@ def get_bound_plugins(plugins):

def downcast_plugins(plugins,
placeholders=None, select_placeholder=False, request=None):
"""
Downcasts the given list of plugins to their respective classes. Ignores any plugins
that are not available.

:param plugins: List of plugins to downcast.
:type plugins: List[CMSPlugin]
:param placeholders: List of placeholders associated with the plugins.
:type placeholders: Optional[List[Placeholder]]
:param select_placeholder: If True, select_related the plugin queryset with placeholder.
:type select_placeholder: bool
:param request: The current request.
:type request: Optional[HttpRequest]
:return: Generator that yields the downcasted plugins.
:rtype: Generator[CMSPlugin, None, None]
"""
plugin_types_map = defaultdict(list)
plugin_lookup = {}
plugin_ids = []
Expand Down Expand Up @@ -333,8 +408,21 @@ def downcast_plugins(plugins,

def has_reached_plugin_limit(placeholder, plugin_type, language, template=None):
"""
Checks if placeholder has reached its global plugin limit,
if not then it checks if it has reached its plugin_type limit.
Checks if the global maximum limit for plugins in a placeholder has been reached.
If not then it checks if it has reached its maximum plugin_type limit.

Parameters:
- placeholder: The placeholder object to check the limit for.
- plugin_type: The type of plugin to check the limit for.
- language: The language code for the plugins.
- template: The template object for the placeholder. Optional.

Returns:
- False if the limit has not been reached.

Raises:
- PluginLimitReached: If the limit has been reached for the placeholder.

"""
limits = get_placeholder_conf("limits", placeholder.slot, template)
if limits:
Expand Down
5 changes: 5 additions & 0 deletions docs/reference/utility-functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ Plugins

.. module:: cms.utils.plugins

.. autofunction:: get_plugins

.. autofunction:: assign_plugins

.. autofunction:: has_reached_plugin_limit
Expand All @@ -57,3 +59,6 @@ Plugins

.. autofunction:: copy_plugins_to_placeholder

.. autofunction:: downcast_plugins

.. autofunction:: get_bound_plugins
0