mirror of
https://github.com/django-cms/django-cms.git
synced 2026-01-16 13:29:00 +03:00
ci: introduce ruff in place of flake8 for improved speed (#7504)
* revert: test change done earlier * feat: replace flake8 with ruff * fix: code cleanup as per ruff recommendations * fix: cleanup code * fix: use flake-to-ruff to convert our config to ruff.toml file * fix: one more bypass * fix: review feedback * fix: cleanup code for usage dict, list and unnecessary usage Authored-by: Vinit Kumar <vinit.kumar@kidskonnect.nl> Signed-off-by: Vinit Kumar <vinit.kumar@kidskonnect.nl> * fix: broken ci tests * fix: isort issues in the forms.py * fix: explanation of the rules bypass * fix: isort issues * revert: changes to the testcases.py * fix: use ruff to format imports * fix: ignore isort for this file as it causes circular import issues * Update cms/toolbar/toolbar.py Co-authored-by: Fabian Braun <fsbraun@gmx.de> * Update cms/api.py Co-authored-by: Fabian Braun <fsbraun@gmx.de> --------- Signed-off-by: Vinit Kumar <vinit.kumar@kidskonnect.nl> Co-authored-by: Fabian Braun <fsbraun@gmx.de>
This commit is contained in:
parent
4c0b3a89d8
commit
ceadcaa70f
37
.github/workflows/linters.yml
vendored
37
.github/workflows/linters.yml
vendored
|
|
@ -6,38 +6,21 @@ concurrency:
|
|||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
flake8:
|
||||
name: flake8
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v3
|
||||
with:
|
||||
python-version: "3.10"
|
||||
cache: 'pip'
|
||||
- run: pip install --upgrade flake8
|
||||
- name: flake8
|
||||
uses: liskin/gh-problem-matcher-wrap@v1
|
||||
with:
|
||||
linters: flake8
|
||||
run: flake8
|
||||
|
||||
isort:
|
||||
jobs:
|
||||
ruff:
|
||||
name: ruff
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v3
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: "3.10"
|
||||
python-version: "3.11"
|
||||
cache: 'pip'
|
||||
- run: python -m pip install isort
|
||||
- name: isort
|
||||
uses: liskin/gh-problem-matcher-wrap@v1
|
||||
with:
|
||||
linters: isort
|
||||
run: isort --check --diff cms
|
||||
- run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install ruff
|
||||
- name: Run Ruff
|
||||
run: ruff cms
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import cms.admin.permissionadmin
|
|||
import cms.admin.settingsadmin
|
||||
import cms.admin.static_placeholder # nopyflakes
|
||||
import cms.admin.useradmin
|
||||
|
||||
# Piggyback off admin.autodiscover() to discover cms plugins
|
||||
from cms import plugin_pool
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@ from django.forms.utils import ErrorList
|
|||
from django.forms.widgets import HiddenInput
|
||||
from django.template.defaultfilters import slugify
|
||||
from django.utils.encoding import force_str
|
||||
from django.utils.translation import gettext, gettext_lazy as _
|
||||
from django.utils.translation import gettext
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from cms import api
|
||||
from cms.apphook_pool import apphook_pool
|
||||
|
|
@ -20,7 +21,15 @@ from cms.extensions import extension_pool
|
|||
from cms.forms.validators import validate_overwrite_url, validate_relative_url, validate_url_uniqueness
|
||||
from cms.forms.widgets import AppHookSelect, ApplicationConfigSelect, UserSelectAdminWidget
|
||||
from cms.models import (
|
||||
CMSPlugin, GlobalPagePermission, Page, PagePermission, PageType, PageUser, PageUserGroup, Placeholder, Title,
|
||||
CMSPlugin,
|
||||
GlobalPagePermission,
|
||||
Page,
|
||||
PagePermission,
|
||||
PageType,
|
||||
PageUser,
|
||||
PageUserGroup,
|
||||
Placeholder,
|
||||
Title,
|
||||
TreeNode,
|
||||
)
|
||||
from cms.models.permissionmodels import User
|
||||
|
|
@ -30,7 +39,10 @@ from cms.utils.compat.forms import UserChangeForm
|
|||
from cms.utils.conf import get_cms_setting
|
||||
from cms.utils.i18n import get_language_list, get_language_object
|
||||
from cms.utils.permissions import (
|
||||
get_current_user, get_subordinate_groups, get_subordinate_users, get_user_permission_level,
|
||||
get_current_user,
|
||||
get_subordinate_groups,
|
||||
get_subordinate_users,
|
||||
get_user_permission_level,
|
||||
)
|
||||
from menus.menu_pool import menu_pool
|
||||
|
||||
|
|
@ -1021,9 +1033,9 @@ class PagePermissionInlineAdminForm(BasePermissionAdminForm):
|
|||
# We can't set a queryset on a raw id lookup, but we can use
|
||||
# the fact that it respects the limit_choices_to parameter.
|
||||
if limit_choices:
|
||||
self.fields['user'].widget.rel.limit_choices_to = dict(
|
||||
id__in=list(sub_users.values_list('pk', flat=True))
|
||||
)
|
||||
self.fields['user'].widget.rel.limit_choices_to = {
|
||||
"id__in": list(sub_users.values_list('pk', flat=True))
|
||||
}
|
||||
else:
|
||||
self.fields['user'].widget = UserSelectAdminWidget()
|
||||
self.fields['user'].queryset = sub_users
|
||||
|
|
|
|||
|
|
@ -17,7 +17,12 @@ from django.core.exceptions import ObjectDoesNotExist, PermissionDenied, Validat
|
|||
from django.db import router, transaction
|
||||
from django.db.models import Prefetch, Q
|
||||
from django.http import (
|
||||
Http404, HttpResponse, HttpResponseBadRequest, HttpResponseForbidden, HttpResponseRedirect, QueryDict,
|
||||
Http404,
|
||||
HttpResponse,
|
||||
HttpResponseBadRequest,
|
||||
HttpResponseForbidden,
|
||||
HttpResponseRedirect,
|
||||
QueryDict,
|
||||
)
|
||||
from django.shortcuts import get_object_or_404, render
|
||||
from django.template.defaultfilters import escape
|
||||
|
|
@ -26,20 +31,37 @@ from django.template.response import SimpleTemplateResponse, TemplateResponse
|
|||
from django.urls import NoReverseMatch, re_path
|
||||
from django.utils.decorators import method_decorator
|
||||
from django.utils.encoding import force_str
|
||||
from django.utils.translation import get_language, gettext, gettext_lazy as _
|
||||
from django.utils.translation import get_language, gettext
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.views.decorators.http import require_POST
|
||||
|
||||
from cms import operations
|
||||
from cms.admin.forms import (
|
||||
AddPageForm, AddPageTypeForm, AdvancedSettingsForm, ChangeListForm, ChangePageForm, CopyPageForm,
|
||||
CopyPermissionForm, DuplicatePageForm, MovePageForm, PagePermissionForm, PublicationDatesForm,
|
||||
AddPageForm,
|
||||
AddPageTypeForm,
|
||||
AdvancedSettingsForm,
|
||||
ChangeListForm,
|
||||
ChangePageForm,
|
||||
CopyPageForm,
|
||||
CopyPermissionForm,
|
||||
DuplicatePageForm,
|
||||
MovePageForm,
|
||||
PagePermissionForm,
|
||||
PublicationDatesForm,
|
||||
)
|
||||
from cms.admin.permissionadmin import PERMISSION_ADMIN_INLINES
|
||||
from cms.admin.placeholderadmin import PlaceholderAdminMixin
|
||||
from cms.cache.permissions import clear_permission_cache
|
||||
from cms.constants import PUBLISHER_STATE_PENDING
|
||||
from cms.models import (
|
||||
CMSPlugin, EmptyTitle, GlobalPagePermission, Page, PagePermission, PageType, StaticPlaceholder, Title,
|
||||
CMSPlugin,
|
||||
EmptyTitle,
|
||||
GlobalPagePermission,
|
||||
Page,
|
||||
PagePermission,
|
||||
PageType,
|
||||
StaticPlaceholder,
|
||||
Title,
|
||||
)
|
||||
from cms.plugin_pool import plugin_pool
|
||||
from cms.signals import post_obj_operation, pre_obj_operation
|
||||
|
|
@ -954,7 +976,7 @@ class BasePageAdmin(PlaceholderAdminMixin, admin.ModelAdmin):
|
|||
if page is None:
|
||||
raise self._get_404_exception(page_id)
|
||||
|
||||
if not target_language or not target_language in get_language_list(site_id=page.node.site_id):
|
||||
if not target_language or target_language not in get_language_list(site_id=page.node.site_id):
|
||||
return HttpResponseBadRequest(force_str(_("Language must be set to a supported language!")))
|
||||
|
||||
for placeholder in page.get_placeholders():
|
||||
|
|
|
|||
|
|
@ -9,7 +9,9 @@ from django.db import OperationalError
|
|||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from cms.admin.forms import (
|
||||
GlobalPagePermissionAdminForm, PagePermissionInlineAdminForm, ViewRestrictionInlineAdminForm,
|
||||
GlobalPagePermissionAdminForm,
|
||||
PagePermissionInlineAdminForm,
|
||||
ViewRestrictionInlineAdminForm,
|
||||
)
|
||||
from cms.exceptions import NoPermissionsException
|
||||
from cms.models import GlobalPagePermission, PagePermission
|
||||
|
|
|
|||
|
|
@ -7,7 +7,11 @@ from django.contrib.admin.utils import get_deleted_objects
|
|||
from django.core.exceptions import PermissionDenied
|
||||
from django.db import router, transaction
|
||||
from django.http import (
|
||||
HttpResponse, HttpResponseBadRequest, HttpResponseForbidden, HttpResponseNotFound, HttpResponseRedirect,
|
||||
HttpResponse,
|
||||
HttpResponseBadRequest,
|
||||
HttpResponseForbidden,
|
||||
HttpResponseNotFound,
|
||||
HttpResponseRedirect,
|
||||
)
|
||||
from django.shortcuts import get_list_or_404, get_object_or_404, render
|
||||
from django.template.response import TemplateResponse
|
||||
|
|
@ -379,7 +383,7 @@ class PlaceholderAdminMixin:
|
|||
source_placeholder = get_object_or_404(Placeholder, pk=source_placeholder_id)
|
||||
target_placeholder = get_object_or_404(Placeholder, pk=target_placeholder_id)
|
||||
|
||||
if not target_language or not target_language in get_language_list():
|
||||
if not target_language or target_language not in get_language_list():
|
||||
return HttpResponseBadRequest(force_str(_("Language must be set to a supported language!")))
|
||||
|
||||
copy_to_clipboard = target_placeholder.pk == request.toolbar.clipboard.pk
|
||||
|
|
|
|||
|
|
@ -12,7 +12,10 @@ from cms.models import Page, PagePermission, PageUser, PageUserGroup
|
|||
from cms.utils.compat.forms import UserAdmin
|
||||
from cms.utils.conf import get_cms_setting
|
||||
from cms.utils.permissions import (
|
||||
get_model_permission_codename, get_subordinate_groups, get_subordinate_users, get_user_permission_level,
|
||||
get_model_permission_codename,
|
||||
get_subordinate_groups,
|
||||
get_subordinate_users,
|
||||
get_user_permission_level,
|
||||
)
|
||||
|
||||
user_model = get_user_model()
|
||||
|
|
|
|||
|
|
@ -446,7 +446,7 @@ def publish_pages(include_unpublished=False, language=None, site=None):
|
|||
qs = qs.filter(node__site=site)
|
||||
|
||||
output_language = None
|
||||
for i, page in enumerate(qs):
|
||||
for page in qs:
|
||||
add = True
|
||||
titles = page.title_set
|
||||
if not include_unpublished:
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ def get_app_urls(urls):
|
|||
if not hasattr(mod, 'urlpatterns'):
|
||||
raise ImproperlyConfigured(
|
||||
"URLConf `%s` has no urlpatterns attribute" % urlconf)
|
||||
yield getattr(mod, 'urlpatterns')
|
||||
yield mod.urlpatterns
|
||||
elif isinstance(urlconf, (list, tuple)):
|
||||
yield urlconf
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -327,7 +327,7 @@ class NavExtender(Modifier):
|
|||
|
||||
# find all not assigned nodes
|
||||
for menu in self.renderer.menus.items():
|
||||
if (hasattr(menu[1], 'cms_enabled') and menu[1].cms_enabled and not menu[0] in exts):
|
||||
if (hasattr(menu[1], 'cms_enabled') and menu[1].cms_enabled and menu[0] not in exts):
|
||||
for node in nodes:
|
||||
if node.namespace == menu[0]:
|
||||
removed.append(node)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
from django.http import HttpResponse, HttpResponseBadRequest, HttpResponseForbidden
|
||||
from django.middleware.csrf import get_token
|
||||
from django.urls import re_path
|
||||
from django.utils.translation import get_language, gettext, gettext_lazy as _
|
||||
from django.utils.translation import get_language, gettext
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from cms.models import CMSPlugin, Placeholder
|
||||
from cms.models.aliaspluginmodel import AliasPluginModel
|
||||
|
|
@ -102,7 +103,7 @@ class AliasPlugin(CMSPluginBase):
|
|||
def create_alias(self, request):
|
||||
if not request.user.is_staff:
|
||||
return HttpResponseForbidden("not enough privileges")
|
||||
if not 'plugin_id' in request.POST and not 'placeholder_id' in request.POST:
|
||||
if "plugin_id" not in request.POST and "placeholder_id" not in request.POST:
|
||||
return HttpResponseBadRequest("plugin_id or placeholder_id POST parameter missing.")
|
||||
plugin = None
|
||||
placeholder = None
|
||||
|
|
|
|||
|
|
@ -5,7 +5,9 @@ from django.contrib.auth.models import AnonymousUser
|
|||
from django.contrib.sites.models import Site
|
||||
from django.db.models import Q
|
||||
from django.urls import NoReverseMatch, Resolver404, resolve, reverse
|
||||
from django.utils.translation import gettext, gettext_lazy as _, override as force_language
|
||||
from django.utils.translation import gettext
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.utils.translation import override as force_language
|
||||
|
||||
from cms.api import can_change_page, get_page_draft
|
||||
from cms.constants import PUBLISHER_STATE_PENDING, TEMPLATE_INHERITANCE_MAGIC
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
from .admin import PageExtensionAdmin # nopyflakes
|
||||
from .admin import TitleExtensionAdmin # nopyflakes
|
||||
from .admin import (
|
||||
PageExtensionAdmin, # nopyflakes
|
||||
TitleExtensionAdmin, # nopyflakes
|
||||
)
|
||||
from .extension_pool import extension_pool # nopyflakes
|
||||
from .models import PageExtension # nopyflakes
|
||||
from .models import TitleExtension # nopyflakes
|
||||
from .models import (
|
||||
PageExtension, # nopyflakes
|
||||
TitleExtension, # nopyflakes
|
||||
)
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class BaseExtension(models.Model):
|
|||
include_parents=True,
|
||||
include_hidden=False,
|
||||
)
|
||||
return list(obj for obj in fields if not isinstance(obj.field, ManyToManyField))
|
||||
return [obj for obj in fields if not isinstance(obj.field, ManyToManyField)]
|
||||
|
||||
def copy(self, target, language):
|
||||
"""
|
||||
|
|
@ -59,7 +59,7 @@ class BaseExtension(models.Model):
|
|||
|
||||
# If the target we're copying already has a publisher counterpart, then
|
||||
# connect the dots.
|
||||
target_prime = getattr(target, 'publisher_public')
|
||||
target_prime = target.publisher_public
|
||||
if target_prime:
|
||||
related_name = self.__class__.__name__.lower()
|
||||
clone_prime = getattr(target_prime, related_name)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@ from django import forms
|
|||
from django.core.exceptions import ValidationError
|
||||
from django.db import transaction
|
||||
from django.utils.text import slugify
|
||||
from django.utils.translation import gettext, gettext_lazy as _
|
||||
from django.utils.translation import gettext
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from cms.admin.forms import AddPageForm
|
||||
from cms.plugin_pool import plugin_pool
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
# isort: skip_file
|
||||
from .settingmodels import * # nopyflakes
|
||||
from .pagemodel import * # nopyflakes
|
||||
from .permissionmodels import * # nopyflakes
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class UrlconfRevision(models.Model):
|
|||
if revision is None:
|
||||
revision = str(uuid.uuid4())
|
||||
obj, created = cls.objects.get_or_create(
|
||||
pk=1, defaults=dict(revision=revision))
|
||||
pk=1, defaults={"revision": revision})
|
||||
return obj.revision, created
|
||||
|
||||
@classmethod
|
||||
|
|
@ -33,7 +33,7 @@ class UrlconfRevision(models.Model):
|
|||
Convenience method for updating the revision.
|
||||
"""
|
||||
obj, created = cls.objects.get_or_create(
|
||||
pk=1, defaults=dict(revision=revision))
|
||||
pk=1, defaults={"revision": revision})
|
||||
if not created:
|
||||
obj.revision = revision
|
||||
obj.save()
|
||||
|
|
|
|||
|
|
@ -344,7 +344,11 @@ class PagePermissionManager(BasicPagePermissionManager):
|
|||
# permissions should be managed on the draft page only
|
||||
|
||||
from cms.models import (
|
||||
ACCESS_CHILDREN, ACCESS_DESCENDANTS, ACCESS_PAGE, ACCESS_PAGE_AND_CHILDREN, ACCESS_PAGE_AND_DESCENDANTS,
|
||||
ACCESS_CHILDREN,
|
||||
ACCESS_DESCENDANTS,
|
||||
ACCESS_PAGE,
|
||||
ACCESS_PAGE_AND_CHILDREN,
|
||||
ACCESS_PAGE_AND_DESCENDANTS,
|
||||
)
|
||||
|
||||
page = page.get_draft_object()
|
||||
|
|
|
|||
|
|
@ -11,13 +11,18 @@ from django.urls import NoReverseMatch, reverse
|
|||
from django.utils.encoding import force_str
|
||||
from django.utils.functional import cached_property
|
||||
from django.utils.timezone import now
|
||||
from django.utils.translation import get_language, gettext_lazy as _, override as force_language
|
||||
from django.utils.translation import get_language
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.utils.translation import override as force_language
|
||||
from treebeard.mp_tree import MP_Node
|
||||
|
||||
from cms import constants
|
||||
from cms.cache.permissions import clear_permission_cache
|
||||
from cms.constants import (
|
||||
PUBLISHER_STATE_DEFAULT, PUBLISHER_STATE_DIRTY, PUBLISHER_STATE_PENDING, TEMPLATE_INHERITANCE_MAGIC,
|
||||
PUBLISHER_STATE_DEFAULT,
|
||||
PUBLISHER_STATE_DIRTY,
|
||||
PUBLISHER_STATE_PENDING,
|
||||
TEMPLATE_INHERITANCE_MAGIC,
|
||||
)
|
||||
from cms.exceptions import LanguageError, PublicIsUnmodifiable, PublicVersionNeeded
|
||||
from cms.models.managers import PageManager, PageNodeManager
|
||||
|
|
|
|||
|
|
@ -217,7 +217,7 @@ class Placeholder(models.Model):
|
|||
include_parents=True,
|
||||
include_hidden=False,
|
||||
)
|
||||
return list(obj for obj in fields)
|
||||
return list(fields)
|
||||
|
||||
def _get_attached_fields(self):
|
||||
"""
|
||||
|
|
@ -568,7 +568,7 @@ class Placeholder(models.Model):
|
|||
'value': force_str(vary_on),
|
||||
})
|
||||
|
||||
return sorted(list(vary_list))
|
||||
return sorted(vary_list)
|
||||
|
||||
def copy_plugins(self, target_placeholder, language=None, root_plugin=None):
|
||||
from cms.utils.plugins import copy_plugins_to_placeholder
|
||||
|
|
|
|||
|
|
@ -410,7 +410,7 @@ class CMSPlugin(MP_Node, metaclass=PluginModelBase):
|
|||
include_parents=True,
|
||||
include_hidden=False,
|
||||
)
|
||||
return list(obj for obj in fields if not isinstance(obj.field, ManyToManyField))
|
||||
return [obj for obj in fields if not isinstance(obj.field, ManyToManyField)]
|
||||
|
||||
def get_position_in_placeholder(self):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ def _handle_no_page(request):
|
|||
resolve('%s$' % request.path)
|
||||
except Resolver404 as e:
|
||||
# raise a django http 404 page
|
||||
exc = Http404(dict(path=request.path, tried=e.args[0]['tried']))
|
||||
exc = Http404({"path": request.path, "tried": e.args[0]['tried']})
|
||||
raise exc
|
||||
raise Http404('CMS Page not found: %s' % request.path)
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@ from django.core.exceptions import ImproperlyConfigured, ObjectDoesNotExist
|
|||
from django.shortcuts import render as render_to_response
|
||||
from django.utils.encoding import force_str
|
||||
from django.utils.html import escapejs
|
||||
from django.utils.translation import gettext, gettext_lazy as _
|
||||
from django.utils.translation import gettext
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from cms import operations
|
||||
from cms.exceptions import SubClassNeededError
|
||||
|
|
@ -386,7 +387,7 @@ class CMSPluginBase(admin.ModelAdmin, metaclass=CMSPluginBaseMetaclass):
|
|||
"""
|
||||
fieldsets = super().get_fieldsets(request, obj)
|
||||
|
||||
for name, data in fieldsets:
|
||||
for _name, data in fieldsets:
|
||||
if data.get('fields'): # if fieldset with non-empty fields is found, return fieldsets
|
||||
return fieldsets
|
||||
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ class BaseRenderer:
|
|||
def get_plugin_class(self, plugin):
|
||||
plugin_type = plugin.plugin_type
|
||||
|
||||
if not plugin_type in self._cached_plugin_classes:
|
||||
if plugin_type not in self._cached_plugin_classes:
|
||||
self._cached_plugin_classes[plugin_type] = self.plugin_pool.get_plugin(plugin_type)
|
||||
return self._cached_plugin_classes[plugin_type]
|
||||
|
||||
|
|
|
|||
|
|
@ -6,8 +6,16 @@ from django.dispatch import Signal
|
|||
from cms.models import GlobalPagePermission, PagePermission, PageUser, PageUserGroup, User
|
||||
from cms.signals.apphook import debug_server_restart, trigger_server_restart
|
||||
from cms.signals.permissions import (
|
||||
post_save_user, post_save_user_group, pre_delete_globalpagepermission, pre_delete_group, pre_delete_pagepermission,
|
||||
pre_delete_user, pre_save_globalpagepermission, pre_save_group, pre_save_pagepermission, pre_save_user,
|
||||
post_save_user,
|
||||
post_save_user_group,
|
||||
pre_delete_globalpagepermission,
|
||||
pre_delete_group,
|
||||
pre_delete_pagepermission,
|
||||
pre_delete_user,
|
||||
pre_save_globalpagepermission,
|
||||
pre_save_group,
|
||||
pre_save_pagepermission,
|
||||
pre_save_user,
|
||||
)
|
||||
from cms.utils.conf import get_cms_setting
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ def debug_server_restart(**kwargs):
|
|||
except NameError: #python3
|
||||
from imp import reload
|
||||
reload(cms.urls)
|
||||
if not 'test' in sys.argv:
|
||||
if 'test' not in sys.argv:
|
||||
msg = 'Application url changed and urls_need_reloading signal fired. ' \
|
||||
'Please reload the urls.py or restart the server.\n'
|
||||
styles = color_style()
|
||||
|
|
|
|||
|
|
@ -63,13 +63,13 @@ def pre_delete_user(instance, **kwargs):
|
|||
|
||||
def pre_save_group(instance, raw, **kwargs):
|
||||
if instance.pk:
|
||||
user_set = getattr(instance, "user_set")
|
||||
user_set = instance.user_set
|
||||
for user in user_set.all():
|
||||
clear_user_permission_cache(user)
|
||||
|
||||
|
||||
def pre_delete_group(instance, **kwargs):
|
||||
user_set = getattr(instance, "user_set")
|
||||
user_set = instance.user_set
|
||||
for user in user_set.all():
|
||||
clear_user_permission_cache(user)
|
||||
|
||||
|
|
@ -78,7 +78,7 @@ def _clear_users_permissions(instance):
|
|||
if instance.user:
|
||||
clear_user_permission_cache(instance.user)
|
||||
if instance.group:
|
||||
user_set = getattr(instance.group, "user_set")
|
||||
user_set = instance.group.user_set
|
||||
for user in user_set.all():
|
||||
clear_user_permission_cache(user)
|
||||
|
||||
|
|
|
|||
|
|
@ -57,9 +57,10 @@ class CMSSitemap(Sitemap):
|
|||
|
||||
def lastmod(self, title):
|
||||
modification_dates = [title.page.changed_date, title.page.publication_date]
|
||||
plugins_for_placeholder = lambda placeholder: placeholder.get_plugins()
|
||||
def plugins_for_placeholder(placeholder):
|
||||
return placeholder.get_plugins()
|
||||
plugins = from_iterable(map(plugins_for_placeholder, title.page.placeholders.all()))
|
||||
plugin_modification_dates = map(lambda plugin: plugin.changed_date, plugins)
|
||||
plugin_modification_dates = (plugin.changed_date for plugin in plugins)
|
||||
modification_dates.extend(plugin_modification_dates)
|
||||
return max(modification_dates)
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class TemplatesCache:
|
|||
if hasattr(template, 'render'):
|
||||
return template
|
||||
|
||||
if not template in self._cached_templates:
|
||||
if template not in self._cached_templates:
|
||||
# this always return a engine-specific template object
|
||||
self._cached_templates[template] = get_template(template)
|
||||
return self._cached_templates[template]
|
||||
|
|
|
|||
|
|
@ -18,12 +18,15 @@ from django.urls import reverse
|
|||
from django.utils.encoding import smart_str
|
||||
from django.utils.html import escape
|
||||
from django.utils.http import urlencode
|
||||
from django.utils.translation import get_language, gettext_lazy as _, override as force_language
|
||||
from django.utils.translation import get_language
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.utils.translation import override as force_language
|
||||
from sekizai.templatetags.sekizai_tags import RenderBlock, SekizaiParser
|
||||
|
||||
from cms.cache.page import get_page_url_cache, set_page_url_cache
|
||||
from cms.exceptions import PlaceholderNotFound
|
||||
from cms.models import CMSPlugin, Page, Placeholder as PlaceholderModel, StaticPlaceholder
|
||||
from cms.models import CMSPlugin, Page, StaticPlaceholder
|
||||
from cms.models import Placeholder as PlaceholderModel
|
||||
from cms.plugin_pool import plugin_pool
|
||||
from cms.toolbar.utils import get_toolbar_from_request
|
||||
from cms.utils import get_current_site, get_language_from_request, get_site_id
|
||||
|
|
@ -393,7 +396,7 @@ class PageAttribute(AsTag):
|
|||
]
|
||||
|
||||
def get_value(self, context, name, page_lookup):
|
||||
if not 'request' in context:
|
||||
if 'request' not in context:
|
||||
return ''
|
||||
name = name.lower()
|
||||
request = context['request']
|
||||
|
|
|
|||
|
|
@ -4,7 +4,10 @@ from django.utils.translation import gettext as _
|
|||
from cms.plugin_base import CMSPluginBase
|
||||
from cms.plugin_pool import plugin_pool
|
||||
from cms.test_utils.project.pluginapp.plugins.manytomany_rel.models import (
|
||||
Article, ArticlePluginModel, PluginModelWithFKFromModel, PluginModelWithM2MToModel,
|
||||
Article,
|
||||
ArticlePluginModel,
|
||||
PluginModelWithFKFromModel,
|
||||
PluginModelWithM2MToModel,
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class MultiColumnPlugin(CMSPluginBase):
|
|||
response = super().save_model(
|
||||
request, obj, form, change
|
||||
)
|
||||
for x in range(int(form.cleaned_data['create'])):
|
||||
for _x in range(int(form.cleaned_data['create'])):
|
||||
col = CMSPlugin(
|
||||
parent=obj,
|
||||
placeholder=obj.placeholder,
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class MultiWrapPlugin(CMSPluginBase):
|
|||
response = super().save_model(
|
||||
request, obj, form, change
|
||||
)
|
||||
for x in range(int(form.cleaned_data['create'])):
|
||||
for _x in range(int(form.cleaned_data['create'])):
|
||||
col = CMSPlugin(
|
||||
parent=obj,
|
||||
placeholder=obj.placeholder,
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ class StaticMenu4(CMSAttachMenu):
|
|||
name = _("Static Menu4")
|
||||
|
||||
def get_nodes(self, request):
|
||||
nodes = list()
|
||||
nodes = []
|
||||
nodes.append(NavigationNode('static fresh', '/static/fresh/', 'static fresh'))
|
||||
nodes.append(NavigationNode('sample2-root', reverse('sample2-root'), 'sample2-root'))
|
||||
return nodes
|
||||
|
|
|
|||
|
|
@ -27,8 +27,13 @@ from cms.models.pluginmodel import CMSPlugin
|
|||
from cms.models.titlemodels import Title
|
||||
from cms.test_utils import testcases as base
|
||||
from cms.test_utils.testcases import (
|
||||
URL_CMS_PAGE, URL_CMS_PAGE_CHANGE, URL_CMS_PAGE_CHANGE_LANGUAGE, URL_CMS_PAGE_DELETE, URL_CMS_PAGE_PUBLISHED,
|
||||
URL_CMS_TRANSLATION_DELETE, CMSTestCase,
|
||||
URL_CMS_PAGE,
|
||||
URL_CMS_PAGE_CHANGE,
|
||||
URL_CMS_PAGE_CHANGE_LANGUAGE,
|
||||
URL_CMS_PAGE_DELETE,
|
||||
URL_CMS_PAGE_PUBLISHED,
|
||||
URL_CMS_TRANSLATION_DELETE,
|
||||
CMSTestCase,
|
||||
)
|
||||
from cms.utils.conf import get_cms_setting
|
||||
from cms.utils.urlutils import admin_reverse
|
||||
|
|
@ -432,7 +437,7 @@ class AdminTests(AdminTestsBase):
|
|||
def get_admin(self):
|
||||
User = get_user_model()
|
||||
|
||||
fields = dict(email="admin@django-cms.org", is_staff=True, is_superuser=True)
|
||||
fields = {"email": "admin@django-cms.org", "is_staff": True, "is_superuser": True}
|
||||
|
||||
if (User.USERNAME_FIELD != 'email'):
|
||||
fields[User.USERNAME_FIELD] = "admin"
|
||||
|
|
@ -445,7 +450,7 @@ class AdminTests(AdminTestsBase):
|
|||
def get_permless(self):
|
||||
User = get_user_model()
|
||||
|
||||
fields = dict(email="permless@django-cms.org", is_staff=True)
|
||||
fields = {"email": "permless@django-cms.org", "is_staff": True}
|
||||
|
||||
if (User.USERNAME_FIELD != 'email'):
|
||||
fields[User.USERNAME_FIELD] = "permless"
|
||||
|
|
@ -744,7 +749,7 @@ class PluginPermissionTests(AdminTestsBase):
|
|||
def _get_admin(self):
|
||||
User = get_user_model()
|
||||
|
||||
fields = dict(email="admin@django-cms.org", is_staff=True, is_active=True)
|
||||
fields = {"email": "admin@django-cms.org", "is_staff": True, "is_active": True}
|
||||
|
||||
if (User.USERNAME_FIELD != 'email'):
|
||||
fields[User.USERNAME_FIELD] = "admin"
|
||||
|
|
@ -806,7 +811,7 @@ class PluginPermissionTests(AdminTestsBase):
|
|||
|
||||
self._give_permission(normal_guy, Text, 'change')
|
||||
url = '{}/edit-plugin/{}/'.format(admin_reverse('cms_page_edit_plugin', args=[plugin.id]), plugin.id)
|
||||
response = self.client.post(url, dict())
|
||||
response = self.client.post(url, {})
|
||||
self.assertEqual(response.status_code, HttpResponseNotFound.status_code)
|
||||
self.assertTrue("Plugin not found" in force_str(response.content))
|
||||
|
||||
|
|
|
|||
|
|
@ -243,5 +243,5 @@ class PythonAPITests(CMSTestCase):
|
|||
rightmost = create_page('r', 'nav_playground.html', 'en', parent=parent)
|
||||
leftmost = create_page('l', 'nav_playground.html', 'en', parent=rightmost, position='left')
|
||||
create_page('m', 'nav_playground.html', 'en', parent=leftmost, position='right')
|
||||
children_titles = list(p.get_title('de') for p in parent.get_child_pages())
|
||||
children_titles = [p.get_title('de') for p in parent.get_child_pages()]
|
||||
self.assertEqual(children_titles, ['l', 'm', 'r'])
|
||||
|
|
|
|||
|
|
@ -582,7 +582,7 @@ class ApphooksTestCase(CMSTestCase):
|
|||
def test_apphooks_receive_url_params(self):
|
||||
# make sure that urlparams actually reach the apphook views
|
||||
self.create_base_structure(APP_NAME, 'en')
|
||||
path = reverse('sample-params', kwargs=dict(my_params='is-my-param-really-in-the-context-QUESTIONMARK'))
|
||||
path = reverse('sample-params', kwargs={"my_params": 'is-my-param-really-in-the-context-QUESTIONMARK'})
|
||||
response = self.client.get(path)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertTemplateUsed(response, 'sampleapp/home.html')
|
||||
|
|
|
|||
|
|
@ -7,16 +7,26 @@ from sekizai.context import SekizaiContext
|
|||
from cms.api import add_plugin, create_page, create_title
|
||||
from cms.cache import _get_cache_version, invalidate_cms_page_cache
|
||||
from cms.cache.placeholder import (
|
||||
_get_placeholder_cache_key, _get_placeholder_cache_version, _get_placeholder_cache_version_key,
|
||||
_set_placeholder_cache_version, clear_placeholder_cache, get_placeholder_cache, set_placeholder_cache,
|
||||
_get_placeholder_cache_key,
|
||||
_get_placeholder_cache_version,
|
||||
_get_placeholder_cache_version_key,
|
||||
_set_placeholder_cache_version,
|
||||
clear_placeholder_cache,
|
||||
get_placeholder_cache,
|
||||
set_placeholder_cache,
|
||||
)
|
||||
from cms.exceptions import PluginAlreadyRegistered
|
||||
from cms.models import Page
|
||||
from cms.plugin_pool import plugin_pool
|
||||
from cms.test_utils.project.placeholderapp.models import Example1
|
||||
from cms.test_utils.project.pluginapp.plugins.caching.cms_plugins import (
|
||||
DateTimeCacheExpirationPlugin, LegacyCachePlugin, NoCachePlugin, SekizaiPlugin, TimeDeltaCacheExpirationPlugin,
|
||||
TTLCacheExpirationPlugin, VaryCacheOnPlugin,
|
||||
DateTimeCacheExpirationPlugin,
|
||||
LegacyCachePlugin,
|
||||
NoCachePlugin,
|
||||
SekizaiPlugin,
|
||||
TimeDeltaCacheExpirationPlugin,
|
||||
TTLCacheExpirationPlugin,
|
||||
VaryCacheOnPlugin,
|
||||
)
|
||||
from cms.test_utils.testcases import CMSTestCase
|
||||
from cms.test_utils.util.fuzzy_int import FuzzyInt
|
||||
|
|
@ -71,10 +81,10 @@ class CacheTestCase(CMSTestCase):
|
|||
'django.middleware.cache.UpdateCacheMiddleware',
|
||||
'django.middleware.cache.FetchFromCacheMiddleware'
|
||||
]
|
||||
overrides = dict(
|
||||
CMS_PAGE_CACHE=False,
|
||||
MIDDLEWARE=[mw for mw in settings.MIDDLEWARE if mw not in exclude],
|
||||
)
|
||||
overrides = {
|
||||
"CMS_PAGE_CACHE": False,
|
||||
"MIDDLEWARE": [mw for mw in settings.MIDDLEWARE if mw not in exclude],
|
||||
}
|
||||
with self.settings(**overrides):
|
||||
with self.assertNumQueries(FuzzyInt(13, 25)):
|
||||
self.client.get(page1_url)
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class Compatibility4xTestCase(testcases.TestCase):
|
|||
migration = os.path.join("cms", "migrations")
|
||||
MAX = 22
|
||||
|
||||
for root, _, files in os.walk(migration):
|
||||
for _root, _, files in os.walk(migration):
|
||||
for name in files:
|
||||
if name == "__init__.py" or not name.endswith(".py"):
|
||||
continue
|
||||
|
|
|
|||
|
|
@ -10,7 +10,10 @@ from cms.extensions import PageExtension, TitleExtension, extension_pool
|
|||
from cms.extensions.toolbar import ExtensionToolbar
|
||||
from cms.models import Page, PageType
|
||||
from cms.test_utils.project.extensionapp.models import (
|
||||
MultiTablePageExtension, MultiTableTitleExtension, MyPageExtension, MyTitleExtension,
|
||||
MultiTablePageExtension,
|
||||
MultiTableTitleExtension,
|
||||
MyPageExtension,
|
||||
MyTitleExtension,
|
||||
)
|
||||
from cms.test_utils.testcases import CMSTestCase
|
||||
from cms.toolbar_pool import toolbar_pool
|
||||
|
|
@ -602,7 +605,7 @@ class ExtensionAdminTestCase(CMSTestCase):
|
|||
if current_page_menu:
|
||||
position = 0
|
||||
urls = self.get_title_extension_admin()
|
||||
for title_extension, url in urls:
|
||||
for _title_extension, url in urls:
|
||||
current_page_menu.add_modal_item(
|
||||
'TestItem',
|
||||
url=url,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
from cms.api import create_page
|
||||
from cms.test_utils.project.sampleapp.models import (
|
||||
PageOnDeleteCascade, PageOnDeleteSetNull, PlaceholderOnDeleteCascade, PlaceholderOnDeleteSetNull,
|
||||
PageOnDeleteCascade,
|
||||
PageOnDeleteSetNull,
|
||||
PlaceholderOnDeleteCascade,
|
||||
PlaceholderOnDeleteSetNull,
|
||||
)
|
||||
from cms.test_utils.testcases import CMSTestCase
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,10 @@ from django.utils.translation import override as force_language
|
|||
|
||||
from cms.admin import forms
|
||||
from cms.admin.forms import (
|
||||
GlobalPagePermissionAdminForm, PagePermissionInlineAdminForm, PageUserGroupForm, ViewRestrictionInlineAdminForm,
|
||||
GlobalPagePermissionAdminForm,
|
||||
PagePermissionInlineAdminForm,
|
||||
PageUserGroupForm,
|
||||
ViewRestrictionInlineAdminForm,
|
||||
)
|
||||
from cms.api import assign_user_to_page, create_page, create_title
|
||||
from cms.forms.fields import PageSelectFormField, SuperLazyIterator
|
||||
|
|
@ -95,7 +98,7 @@ class FormsTestCase(CMSTestCase):
|
|||
# boilerplate (creating a page)
|
||||
User = get_user_model()
|
||||
|
||||
fields = dict(is_staff=True, is_active=True, is_superuser=True, email="super@super.com")
|
||||
fields = {"is_staff": True, "is_active": True, "is_superuser": True, "email": "super@super.com"}
|
||||
|
||||
if User.USERNAME_FIELD != 'email':
|
||||
fields[User.USERNAME_FIELD] = "super"
|
||||
|
|
@ -136,7 +139,7 @@ class FormsTestCase(CMSTestCase):
|
|||
# boilerplate (creating a page)
|
||||
User = get_user_model()
|
||||
|
||||
fields = dict(is_staff=True, is_active=True, is_superuser=True, email="super@super.com")
|
||||
fields = {"is_staff": True, "is_active": True, "is_superuser": True, "email": "super@super.com"}
|
||||
|
||||
if User.USERNAME_FIELD != 'email':
|
||||
fields[User.USERNAME_FIELD] = "super"
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@ from django.contrib.sites.models import Site
|
|||
from django.template import Template, TemplateSyntaxError
|
||||
from django.template.context import Context
|
||||
from django.test.utils import override_settings
|
||||
from django.utils.translation import activate, override as force_language
|
||||
from django.utils.translation import activate
|
||||
from django.utils.translation import override as force_language
|
||||
|
||||
from cms.api import create_page, create_title
|
||||
from cms.apphook_pool import apphook_pool
|
||||
|
|
@ -36,7 +37,7 @@ class BaseMenuTest(CMSTestCase):
|
|||
node4 = NavigationNode('4', '/4/', 4, 2)
|
||||
node5 = NavigationNode('5', '/5/', 5)
|
||||
nodes = [node1, node2, node3, node4, node5]
|
||||
tree = _build_nodes_inner_for_one_menu([n for n in nodes], "test")
|
||||
tree = _build_nodes_inner_for_one_menu(list(nodes), "test")
|
||||
request = self.get_request(path)
|
||||
renderer = menu_pool.get_renderer(request)
|
||||
renderer.apply_modifiers(tree, request)
|
||||
|
|
@ -162,7 +163,7 @@ class MenuDiscoveryTest(ExtendedMenusFixture, CMSTestCase):
|
|||
# (which is not) and checks the key name for the StaticMenu instances
|
||||
static_menus = 2
|
||||
static_menus_2 = 1
|
||||
for key, menu in menus.items():
|
||||
for key, _menu in menus.items():
|
||||
if key.startswith('StaticMenu:'):
|
||||
static_menus -= 1
|
||||
self.assertTrue(key.endswith(str(page.get_public_object().pk)) or key.endswith(str(page.get_draft_object().pk)))
|
||||
|
|
@ -518,7 +519,7 @@ class FixturesMenuTests(MenusFixture, BaseMenuTest):
|
|||
context['request'].session['cms_edit'] = True
|
||||
Template("{% load menu_tags %}{% show_menu %}").render(context)
|
||||
# All nodes should be public nodes because the request page is public
|
||||
nodes = [node for node in context['children']]
|
||||
nodes = list(context['children'])
|
||||
node_ids = [node.id for node in nodes]
|
||||
page_count = Page.objects.public().filter(pk__in=node_ids).count()
|
||||
self.assertEqual(len(node_ids), page_count, msg='Not all pages in the public menu are public')
|
||||
|
|
@ -1856,7 +1857,7 @@ class PublicViewPermissionMenuTests(CMSTestCase):
|
|||
C1 C2 C3 C4
|
||||
"""
|
||||
template = 'nav_playground.html'
|
||||
kw = dict(published=True, in_navigation=True)
|
||||
kw = {"published": True, "in_navigation": True}
|
||||
a = create_page('a', template, 'en', **kw)
|
||||
b1 = create_page('b1', template, 'en', parent=a, **kw)
|
||||
b2 = create_page('b2', template, 'en', parent=a, **kw)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,12 @@ from django.test.utils import override_settings
|
|||
from cms.api import create_page
|
||||
from cms.cms_menus import get_visible_nodes
|
||||
from cms.models import (
|
||||
ACCESS_CHILDREN, ACCESS_DESCENDANTS, ACCESS_PAGE, ACCESS_PAGE_AND_CHILDREN, ACCESS_PAGE_AND_DESCENDANTS, Page,
|
||||
ACCESS_CHILDREN,
|
||||
ACCESS_DESCENDANTS,
|
||||
ACCESS_PAGE,
|
||||
ACCESS_PAGE_AND_CHILDREN,
|
||||
ACCESS_PAGE_AND_DESCENDANTS,
|
||||
Page,
|
||||
)
|
||||
from cms.models.permissionmodels import GlobalPagePermission, PagePermission
|
||||
from cms.test_utils.testcases import CMSTestCase
|
||||
|
|
@ -146,7 +151,7 @@ class ViewPermissionTests(CMSTestCase):
|
|||
user = self._create_user(username, is_staff)
|
||||
if groupname:
|
||||
group, _ = Group.objects.get_or_create(name=groupname)
|
||||
user_set = getattr(group, 'user_set')
|
||||
user_set = group.user_set
|
||||
user_set.add(user)
|
||||
group.save()
|
||||
|
||||
|
|
@ -241,7 +246,7 @@ class ViewPermissionTests(CMSTestCase):
|
|||
if get_user_model().USERNAME_FIELD == 'email':
|
||||
username = username + '@django-cms.org'
|
||||
|
||||
query = dict()
|
||||
query = {}
|
||||
query[get_user_model().USERNAME_FIELD+'__iexact'] = username
|
||||
user = get_user_model().objects.get(**query)
|
||||
request = self.get_request(user)
|
||||
|
|
@ -583,7 +588,7 @@ class ViewPermissionTreeBugTests(ViewPermissionTests):
|
|||
def _setup_user(self):
|
||||
user = self._create_user('user_6', True)
|
||||
group = Group.objects.create(name=self.GROUPNAME_6)
|
||||
user_set = getattr(group, 'user_set')
|
||||
user_set = group.user_set
|
||||
user_set.add(user)
|
||||
group.save()
|
||||
|
||||
|
|
|
|||
|
|
@ -16,13 +16,13 @@ from cms.test_utils.testcases import URL_CMS_PAGE_ADD, URL_CMS_PAGE_CHANGE_TEMPL
|
|||
from cms.toolbar.toolbar import CMSToolbar
|
||||
from cms.utils.conf import get_cms_setting
|
||||
|
||||
overrides = dict(
|
||||
LANGUAGE_CODE='en-us',
|
||||
LANGUAGES=[],
|
||||
CMS_LANGUAGES={},
|
||||
USE_I18N=False,
|
||||
ROOT_URLCONF='cms.test_utils.project.urls_no18n',
|
||||
TEMPLATE_CONTEXT_PROCESSORS=[
|
||||
overrides = {
|
||||
"LANGUAGE_CODE": 'en-us',
|
||||
"LANGUAGES": [],
|
||||
"CMS_LANGUAGES": {},
|
||||
"USE_I18N": False,
|
||||
"ROOT_URLCONF": 'cms.test_utils.project.urls_no18n',
|
||||
"TEMPLATE_CONTEXT_PROCESSORS": [
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
'django.core.context_processors.debug',
|
||||
|
|
@ -33,7 +33,7 @@ overrides = dict(
|
|||
'sekizai.context_processors.sekizai',
|
||||
'django.core.context_processors.static',
|
||||
],
|
||||
MIDDLEWARE=[
|
||||
"MIDDLEWARE": [
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
|
|
@ -44,7 +44,7 @@ overrides = dict(
|
|||
'cms.middleware.page.CurrentPageMiddleware',
|
||||
'cms.middleware.toolbar.ToolbarMiddleware',
|
||||
]
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@override_settings(**overrides)
|
||||
|
|
@ -112,11 +112,11 @@ class TestNoI18N(CMSTestCase):
|
|||
self.assertEqual(url, "%s" % path)
|
||||
|
||||
def test_url_redirect(self):
|
||||
overrides = dict(
|
||||
USE_I18N=True,
|
||||
CMS_LANGUAGES={1: []},
|
||||
LANGUAGES=[('en-us', 'English')],
|
||||
MIDDLEWARE=[
|
||||
overrides = {
|
||||
"USE_I18N": True,
|
||||
"CMS_LANGUAGES": {1: []},
|
||||
"LANGUAGES": [('en-us', 'English')],
|
||||
"MIDDLEWARE": [
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
|
|
@ -128,7 +128,7 @@ class TestNoI18N(CMSTestCase):
|
|||
'cms.middleware.page.CurrentPageMiddleware',
|
||||
'cms.middleware.toolbar.ToolbarMiddleware',
|
||||
]
|
||||
)
|
||||
}
|
||||
with self.settings(**overrides):
|
||||
homepage = create_page(
|
||||
"home",
|
||||
|
|
|
|||
|
|
@ -12,7 +12,8 @@ from django.core.exceptions import ValidationError
|
|||
from django.http import HttpResponse, HttpResponseNotFound
|
||||
from django.urls import reverse
|
||||
from django.utils.timezone import now as tz_now
|
||||
from django.utils.translation import activate, override as force_language
|
||||
from django.utils.translation import activate
|
||||
from django.utils.translation import override as force_language
|
||||
|
||||
from cms import constants
|
||||
from cms.api import add_plugin, create_page, create_title, publish_page
|
||||
|
|
@ -201,7 +202,7 @@ class PagesTestCase(TransactionCMSTestCase):
|
|||
""" Checks cms.utils.page.get_available_slug for infinite recursion
|
||||
"""
|
||||
site = get_current_site()
|
||||
for x in range(0, 12):
|
||||
for _x in range(0, 12):
|
||||
create_page('test copy', 'nav_playground.html', 'en', published=True)
|
||||
new_slug = get_available_slug(site, 'test-copy', 'en')
|
||||
self.assertTrue(new_slug, 'test-copy-11')
|
||||
|
|
|
|||
|
|
@ -30,7 +30,12 @@ from cms.models.pluginmodel import CMSPlugin
|
|||
from cms.models.titlemodels import EmptyTitle, Title
|
||||
from cms.test_utils.project.sampleapp.models import SampleAppConfig
|
||||
from cms.test_utils.testcases import (
|
||||
URL_CMS_PAGE, URL_CMS_PAGE_ADD, URL_CMS_PAGE_ADVANCED_CHANGE, URL_CMS_PAGE_CHANGE, URL_CMS_PAGE_MOVE, CMSTestCase,
|
||||
URL_CMS_PAGE,
|
||||
URL_CMS_PAGE_ADD,
|
||||
URL_CMS_PAGE_ADVANCED_CHANGE,
|
||||
URL_CMS_PAGE_CHANGE,
|
||||
URL_CMS_PAGE_MOVE,
|
||||
CMSTestCase,
|
||||
)
|
||||
from cms.test_utils.util.context_managers import LanguageOverride, UserLoginContext
|
||||
from cms.utils.compat.dj import installed_apps
|
||||
|
|
|
|||
|
|
@ -8,7 +8,10 @@ from cms.models import Page
|
|||
from cms.models.permissionmodels import ACCESS_PAGE_AND_DESCENDANTS, GlobalPagePermission
|
||||
from cms.test_utils.testcases import URL_CMS_PAGE_ADD, CMSTestCase
|
||||
from cms.utils.page_permissions import (
|
||||
get_change_id_list, user_can_add_subpage, user_can_publish_page, user_can_view_page,
|
||||
get_change_id_list,
|
||||
user_can_add_subpage,
|
||||
user_can_publish_page,
|
||||
user_can_view_page,
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,10 @@ from cms.api import add_plugin, assign_user_to_page, create_page, create_page_us
|
|||
from cms.cms_menus import get_visible_nodes
|
||||
from cms.models import ACCESS_PAGE, CMSPlugin, Page, Title
|
||||
from cms.models.permissionmodels import (
|
||||
ACCESS_DESCENDANTS, ACCESS_PAGE_AND_DESCENDANTS, GlobalPagePermission, PagePermission,
|
||||
ACCESS_DESCENDANTS,
|
||||
ACCESS_PAGE_AND_DESCENDANTS,
|
||||
GlobalPagePermission,
|
||||
PagePermission,
|
||||
)
|
||||
from cms.test_utils.testcases import URL_CMS_PAGE_ADD, CMSTestCase
|
||||
from cms.test_utils.util.fuzzy_int import FuzzyInt
|
||||
|
|
|
|||
|
|
@ -28,7 +28,11 @@ from cms.toolbar.toolbar import CMSToolbar
|
|||
from cms.toolbar.utils import get_toolbar_from_request
|
||||
from cms.utils.conf import get_cms_setting
|
||||
from cms.utils.placeholder import (
|
||||
MLNGPlaceholderActions, PlaceholderNoAction, _get_nodelist, _scan_placeholders, get_placeholder_conf,
|
||||
MLNGPlaceholderActions,
|
||||
PlaceholderNoAction,
|
||||
_get_nodelist,
|
||||
_scan_placeholders,
|
||||
get_placeholder_conf,
|
||||
get_placeholders,
|
||||
)
|
||||
from cms.utils.plugins import assign_plugins, has_reached_plugin_limit
|
||||
|
|
|
|||
|
|
@ -1,8 +1,15 @@
|
|||
from cms.api import add_plugin
|
||||
from cms.models import Page, Placeholder, UserSettings
|
||||
from cms.operations import (
|
||||
ADD_PLUGIN, ADD_PLUGINS_FROM_PLACEHOLDER, CHANGE_PLUGIN, CLEAR_PLACEHOLDER, CUT_PLUGIN, DELETE_PLUGIN, MOVE_PLUGIN,
|
||||
PASTE_PLACEHOLDER, PASTE_PLUGIN,
|
||||
ADD_PLUGIN,
|
||||
ADD_PLUGINS_FROM_PLACEHOLDER,
|
||||
CHANGE_PLUGIN,
|
||||
CLEAR_PLACEHOLDER,
|
||||
CUT_PLUGIN,
|
||||
DELETE_PLUGIN,
|
||||
MOVE_PLUGIN,
|
||||
PASTE_PLACEHOLDER,
|
||||
PASTE_PLUGIN,
|
||||
)
|
||||
from cms.signals import post_placeholder_operation, pre_placeholder_operation
|
||||
from cms.test_utils.testcases import CMSTestCase
|
||||
|
|
|
|||
|
|
@ -27,16 +27,32 @@ from cms.plugin_base import CMSPluginBase
|
|||
from cms.plugin_pool import plugin_pool
|
||||
from cms.sitemaps.cms_sitemap import CMSSitemap
|
||||
from cms.test_utils.project.pluginapp.plugins.manytomany_rel.models import (
|
||||
Article, ArticlePluginModel, FKModel, M2MTargetModel, Section,
|
||||
Article,
|
||||
ArticlePluginModel,
|
||||
FKModel,
|
||||
M2MTargetModel,
|
||||
Section,
|
||||
)
|
||||
from cms.test_utils.project.pluginapp.plugins.meta.cms_plugins import (
|
||||
TestPlugin, TestPlugin2, TestPlugin3, TestPlugin4, TestPlugin5,
|
||||
TestPlugin,
|
||||
TestPlugin2,
|
||||
TestPlugin3,
|
||||
TestPlugin4,
|
||||
TestPlugin5,
|
||||
)
|
||||
from cms.test_utils.project.pluginapp.plugins.validation.cms_plugins import (
|
||||
DynTemplate, NonExisitngRenderTemplate, NoRender, NoRenderButChildren,
|
||||
DynTemplate,
|
||||
NonExisitngRenderTemplate,
|
||||
NoRender,
|
||||
NoRenderButChildren,
|
||||
)
|
||||
from cms.test_utils.testcases import (
|
||||
URL_CMS_PAGE, URL_CMS_PAGE_ADD, URL_CMS_PAGE_CHANGE, URL_CMS_PAGE_PUBLISH, URL_CMS_PLUGIN_ADD, CMSTestCase,
|
||||
URL_CMS_PAGE,
|
||||
URL_CMS_PAGE_ADD,
|
||||
URL_CMS_PAGE_CHANGE,
|
||||
URL_CMS_PAGE_PUBLISH,
|
||||
URL_CMS_PLUGIN_ADD,
|
||||
CMSTestCase,
|
||||
)
|
||||
from cms.test_utils.util.fuzzy_int import FuzzyInt
|
||||
from cms.toolbar.toolbar import CMSToolbar
|
||||
|
|
@ -958,7 +974,7 @@ class PluginsTestCase(PluginsTestBaseCase):
|
|||
in the plugin pool when a placeholder is specified
|
||||
"""
|
||||
ParentRequiredPlugin = type('ParentRequiredPlugin', (CMSPluginBase,),
|
||||
dict(require_parent=True, render_plugin=False))
|
||||
{"require_parent": True, "render_plugin": False})
|
||||
|
||||
with register_plugins(ParentRequiredPlugin):
|
||||
page = api.create_page("page", "nav_playground.html", "en", published=True)
|
||||
|
|
@ -1028,7 +1044,7 @@ class PluginsTestCase(PluginsTestBaseCase):
|
|||
placeholder = page.placeholders.get(slot='body')
|
||||
ChildClassesPlugin = type(
|
||||
'ChildClassesPlugin', (CMSPluginBase,),
|
||||
dict(child_classes=['TextPlugin'], render_template='allow_children_plugin.html')
|
||||
{"child_classes": ['TextPlugin'], "render_template": 'allow_children_plugin.html'}
|
||||
)
|
||||
|
||||
with register_plugins(ChildClassesPlugin):
|
||||
|
|
@ -1053,7 +1069,7 @@ class PluginsTestCase(PluginsTestBaseCase):
|
|||
placeholder = page.placeholders.get(slot='body')
|
||||
ParentClassesPlugin = type(
|
||||
'ParentClassesPlugin', (CMSPluginBase,),
|
||||
dict(parent_classes=['TextPlugin'], render_plugin=False)
|
||||
{"parent_classes": ['TextPlugin'], "render_plugin": False}
|
||||
)
|
||||
|
||||
with register_plugins(ParentClassesPlugin):
|
||||
|
|
@ -1077,11 +1093,11 @@ class PluginsTestCase(PluginsTestBaseCase):
|
|||
page = api.create_page("page", "nav_playground.html", "en", published=True)
|
||||
placeholder = page.placeholders.get(slot='body')
|
||||
ParentPlugin = type(
|
||||
'ParentPlugin', (CMSPluginBase,), dict(render_plugin=False)
|
||||
'ParentPlugin', (CMSPluginBase,), {"render_plugin": False}
|
||||
)
|
||||
ChildPlugin = type(
|
||||
'ChildPlugin', (CMSPluginBase,),
|
||||
dict(parent_classes=['ParentPlugin'], render_plugin=False)
|
||||
{"parent_classes": ['ParentPlugin'], "render_plugin": False}
|
||||
)
|
||||
|
||||
with register_plugins(ParentPlugin, ChildPlugin):
|
||||
|
|
@ -1097,11 +1113,11 @@ class PluginsTestCase(PluginsTestBaseCase):
|
|||
placeholder = page.placeholders.get(slot='body')
|
||||
ParentPlugin = type(
|
||||
'ParentPlugin', (CMSPluginBase,),
|
||||
dict(render_plugin=False)
|
||||
{"render_plugin": False}
|
||||
)
|
||||
ChildPlugin = type(
|
||||
'ChildPlugin', (CMSPluginBase,),
|
||||
dict(require_parent=True, render_plugin=False)
|
||||
{"require_parent": True, "render_plugin": False}
|
||||
)
|
||||
|
||||
with register_plugins(ParentPlugin, ChildPlugin):
|
||||
|
|
@ -1513,8 +1529,15 @@ class MTIPluginsTestCase(PluginsTestBaseCase):
|
|||
|
||||
def test_related_name(self):
|
||||
from cms.test_utils.project.mti_pluginapp.models import (
|
||||
AbstractPluginParent, LessMixedPlugin, MixedPlugin, NonPluginModel, ProxiedAlphaPluginModel,
|
||||
ProxiedBetaPluginModel, TestPluginAlphaModel, TestPluginBetaModel, TestPluginGammaModel,
|
||||
AbstractPluginParent,
|
||||
LessMixedPlugin,
|
||||
MixedPlugin,
|
||||
NonPluginModel,
|
||||
ProxiedAlphaPluginModel,
|
||||
ProxiedBetaPluginModel,
|
||||
TestPluginAlphaModel,
|
||||
TestPluginBetaModel,
|
||||
TestPluginGammaModel,
|
||||
)
|
||||
|
||||
# the first concrete class of the following four plugins is TestPluginAlphaModel
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ def compile_messages():
|
|||
raise CommandError("This script should be run from the Django SVN tree or your project or app tree, or with the settings module specified.")
|
||||
|
||||
for basedir in basedirs:
|
||||
for dirpath, dirnames, filenames in os.walk(basedir):
|
||||
for dirpath, _dirnames, filenames in os.walk(basedir):
|
||||
for f in filenames:
|
||||
if f.endswith('.po'):
|
||||
if DJANGO_2_2 or DJANGO_3_0 or DJANGO_3_1:
|
||||
|
|
|
|||
|
|
@ -875,7 +875,7 @@ class PublishingTests(TestCase):
|
|||
|
||||
child_nodes = list(TreeNode.objects.filter(parent__isnull=False))
|
||||
|
||||
for idx, node in enumerate(child_nodes):
|
||||
for _idx, node in enumerate(child_nodes):
|
||||
self.assertEqual(node.path[0:4], node.parent.path[0:4])
|
||||
self.assertTrue(node.parent in node.get_ancestors())
|
||||
self.assertTrue(node in node.parent.get_descendants())
|
||||
|
|
@ -889,7 +889,7 @@ class PublishingTests(TestCase):
|
|||
|
||||
child_nodes = list(TreeNode.objects.filter(parent__isnull=False))
|
||||
|
||||
for idx, node in enumerate(child_nodes):
|
||||
for _idx, node in enumerate(child_nodes):
|
||||
self.assertEqual(node.path[0:4], node.parent.path[0:4])
|
||||
self.assertTrue(node.parent in node.get_ancestors())
|
||||
self.assertTrue(node in node.parent.get_descendants())
|
||||
|
|
|
|||
|
|
@ -22,8 +22,13 @@ from django.utils.translation import gettext_lazy as _
|
|||
from cms.admin.forms import RequestToolbarForm
|
||||
from cms.api import add_plugin, create_page, create_title
|
||||
from cms.cms_toolbars import (
|
||||
ADMIN_MENU_IDENTIFIER, ADMINISTRATION_BREAK, DEFAULT_HELP_MENU_ITEMS, HELP_MENU_IDENTIFIER,
|
||||
LANGUAGE_MENU_IDENTIFIER, AppearanceToolbar, get_user_model,
|
||||
ADMIN_MENU_IDENTIFIER,
|
||||
ADMINISTRATION_BREAK,
|
||||
DEFAULT_HELP_MENU_ITEMS,
|
||||
HELP_MENU_IDENTIFIER,
|
||||
LANGUAGE_MENU_IDENTIFIER,
|
||||
AppearanceToolbar,
|
||||
get_user_model,
|
||||
)
|
||||
from cms.constants import PUBLISHER_STATE_DIRTY
|
||||
from cms.middleware.toolbar import ToolbarMiddleware
|
||||
|
|
@ -689,7 +694,7 @@ class ToolbarTests(ToolbarTestBase):
|
|||
toolbar = CMSToolbar(request)
|
||||
renderer = toolbar.get_content_renderer()
|
||||
# TextPlugin needs request in context
|
||||
renderer.render_static_placeholder(static_placeholder, RequestContext(request, dict(request=request)))
|
||||
renderer.render_static_placeholder(static_placeholder, RequestContext(request, {"request": request}))
|
||||
toolbar.populate()
|
||||
toolbar.post_template_populate()
|
||||
|
||||
|
|
@ -1017,9 +1022,9 @@ class ToolbarTests(ToolbarTestBase):
|
|||
}
|
||||
self.assertIn(name, list(menu))
|
||||
if items is not None:
|
||||
sub_menu = list(
|
||||
sub_menu = [
|
||||
force_str(getattr(item, 'name', '|')) for item in menu[name].get_items()
|
||||
)
|
||||
]
|
||||
self.assertEqual(sorted(sub_menu), sorted(items))
|
||||
|
||||
def test_remove_language(self):
|
||||
|
|
|
|||
|
|
@ -190,7 +190,7 @@ class TestWizardPool(WizardTestMixin, CMSTestCase):
|
|||
wizard_pool.register(self.page_wizard)
|
||||
wizard_pool.register(self.user_settings_wizard)
|
||||
wizards = [self.page_wizard, self.user_settings_wizard]
|
||||
wizards = sorted(wizards, key=lambda e: getattr(e, 'weight'))
|
||||
wizards = sorted(wizards, key=lambda e: e.weight)
|
||||
entries = wizard_pool.get_entries()
|
||||
self.assertSequencesEqual(entries, wizards)
|
||||
|
||||
|
|
@ -198,7 +198,7 @@ class TestWizardPool(WizardTestMixin, CMSTestCase):
|
|||
wizard_pool.register(self.user_settings_wizard)
|
||||
wizard_pool.register(self.page_wizard)
|
||||
wizards = [self.page_wizard, self.user_settings_wizard]
|
||||
wizards = sorted(wizards, key=lambda e: getattr(e, 'weight'))
|
||||
wizards = sorted(wizards, key=lambda e: e.weight)
|
||||
entries = wizard_pool.get_entries()
|
||||
self.assertSequencesEqual(entries, wizards)
|
||||
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ class CMSToolbar(BaseToolbar):
|
|||
self.clipboard = user_settings.clipboard
|
||||
|
||||
if hasattr(self, 'toolbars'):
|
||||
for key, toolbar in self.toolbars.items():
|
||||
for key in self.toolbars:
|
||||
self.toolbars[key].request = self.request
|
||||
self.request_path = request_path or request.path
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import json
|
||||
|
||||
from django.utils.encoding import force_str
|
||||
from django.utils.translation import gettext, override as force_language
|
||||
from django.utils.translation import gettext
|
||||
from django.utils.translation import override as force_language
|
||||
|
||||
from cms.constants import PLACEHOLDER_TOOLBAR_JS, PLUGIN_TOOLBAR_JS
|
||||
|
||||
|
|
|
|||
|
|
@ -25,12 +25,12 @@ def get_language_from_request(request, current_page=None):
|
|||
site_id = current_page.node.site_id if current_page else None
|
||||
if language:
|
||||
language = get_language_code(language)
|
||||
if not language in get_language_list(site_id):
|
||||
if language not in get_language_list(site_id):
|
||||
language = None
|
||||
if not language:
|
||||
language = get_language_code(getattr(request, 'LANGUAGE_CODE', None))
|
||||
if language:
|
||||
if not language in get_language_list(site_id):
|
||||
if language not in get_language_list(site_id):
|
||||
language = None
|
||||
|
||||
if not language and current_page:
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ from django.apps import apps
|
|||
from django.conf import settings
|
||||
|
||||
# override with custom classes if they exist
|
||||
# noqa is used to avoid flake8 errors, as this is not used in
|
||||
# the same file but imported in other files
|
||||
if settings.AUTH_USER_MODEL != 'auth.User': # pragma: no cover
|
||||
# UserAdmin class
|
||||
user_app_name = settings.AUTH_USER_MODEL.split('.')[0]
|
||||
|
|
@ -17,7 +19,7 @@ if settings.AUTH_USER_MODEL != 'auth.User': # pragma: no cover
|
|||
else:
|
||||
from django.contrib.auth.admin import UserAdmin
|
||||
except ImportError:
|
||||
from django.contrib.auth.admin import UserAdmin # nopyflakes
|
||||
from django.contrib.auth.admin import UserAdmin # noqa
|
||||
|
||||
# user form classes
|
||||
try:
|
||||
|
|
@ -31,11 +33,11 @@ if settings.AUTH_USER_MODEL != 'auth.User': # pragma: no cover
|
|||
if hasattr(custom_forms, 'UserChangeForm'):
|
||||
UserChangeForm = custom_forms.UserChangeForm
|
||||
else:
|
||||
from django.contrib.auth.forms import UserChangeForm
|
||||
from django.contrib.auth.forms import UserChangeForm # noqa
|
||||
except ImportError:
|
||||
from django.contrib.auth.forms import UserChangeForm # nopyflakes
|
||||
from django.contrib.auth.forms import UserCreationForm # nopyflakes
|
||||
from django.contrib.auth.forms import UserChangeForm # noqa
|
||||
from django.contrib.auth.forms import UserCreationForm # noqa
|
||||
else:
|
||||
from django.contrib.auth.admin import UserAdmin # nopyflakes
|
||||
from django.contrib.auth.forms import UserChangeForm # nopyflakes
|
||||
from django.contrib.auth.forms import UserCreationForm # nopyflakes
|
||||
from django.contrib.auth.admin import UserAdmin # noqa
|
||||
from django.contrib.auth.forms import UserChangeForm # noqa
|
||||
from django.contrib.auth.forms import UserCreationForm # noqa
|
||||
|
|
@ -172,7 +172,7 @@ def get_templates():
|
|||
template_module = _load_from_file(config_path)
|
||||
templates = [(os.path.join(prefix, data[0].strip()), data[1]) for data in template_module.TEMPLATES.items()]
|
||||
else:
|
||||
templates = list((os.path.join(prefix, tpl), tpl) for tpl in os.listdir(tpldir))
|
||||
templates = [(os.path.join(prefix, tpl), tpl) for tpl in os.listdir(tpldir)]
|
||||
else:
|
||||
templates = list(getattr(settings, 'CMS_TEMPLATES', []))
|
||||
if get_cms_setting('TEMPLATE_INHERITANCE'):
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ def get_default_language(language_code=None, site_id=None):
|
|||
# otherwise split the language code if possible, so iso3
|
||||
language_code = language_code.split("-")[0]
|
||||
|
||||
if not language_code in languages:
|
||||
if language_code not in languages:
|
||||
return settings.LANGUAGE_CODE
|
||||
|
||||
return language_code
|
||||
|
|
|
|||
|
|
@ -8,7 +8,10 @@ from cms.utils import get_current_site
|
|||
from cms.utils.compat.dj import available_attrs
|
||||
from cms.utils.conf import get_cms_setting
|
||||
from cms.utils.permissions import (
|
||||
cached_func, get_model_permission_codename, get_page_actions_for_user, has_global_permission,
|
||||
cached_func,
|
||||
get_model_permission_codename,
|
||||
get_page_actions_for_user,
|
||||
has_global_permission,
|
||||
)
|
||||
|
||||
PAGE_ADD_CODENAME = get_model_permission_codename(Page, 'add')
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ def get_plugins(request, placeholder, template, lang=None):
|
|||
return []
|
||||
if not hasattr(placeholder, '_plugins_cache'):
|
||||
assign_plugins(request, [placeholder], template, lang)
|
||||
return getattr(placeholder, '_plugins_cache')
|
||||
return placeholder._plugins_cache
|
||||
|
||||
|
||||
def assign_plugins(request, placeholders, template=None, lang=None, is_fallback=False):
|
||||
|
|
@ -80,9 +80,9 @@ def assign_plugins(request, placeholders, template=None, lang=None, is_fallback=
|
|||
groups.update(plugin_groups)
|
||||
for placeholder in placeholders:
|
||||
# This is all the plugins.
|
||||
setattr(placeholder, '_all_plugins_cache', all_plugins_groups.get(placeholder.pk, []))
|
||||
placeholder._all_plugins_cache = all_plugins_groups.get(placeholder.pk, [])
|
||||
# This one is only the root plugins.
|
||||
setattr(placeholder, '_plugins_cache', groups.get(placeholder.pk, []))
|
||||
placeholder._plugins_cache = groups.get(placeholder.pk, [])
|
||||
|
||||
|
||||
def create_default_plugins(request, placeholders, template, lang):
|
||||
|
|
|
|||
11
cms/views.py
11
cms/views.py
|
|
@ -1,7 +1,8 @@
|
|||
from urllib.parse import quote
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib.auth import REDIRECT_FIELD_NAME, login as auth_login
|
||||
from django.contrib.auth import REDIRECT_FIELD_NAME
|
||||
from django.contrib.auth import login as auth_login
|
||||
from django.contrib.auth.views import redirect_to_login
|
||||
from django.http import HttpResponse, HttpResponseRedirect
|
||||
from django.urls import reverse
|
||||
|
|
@ -21,8 +22,12 @@ from cms.utils import get_current_site
|
|||
from cms.utils.compat import DJANGO_2_2, DJANGO_3_0, DJANGO_3_1
|
||||
from cms.utils.conf import get_cms_setting
|
||||
from cms.utils.i18n import (
|
||||
get_default_language_for_site, get_fallback_languages, get_language_list, get_public_languages,
|
||||
get_redirect_on_fallback, is_language_prefix_patterns_used,
|
||||
get_default_language_for_site,
|
||||
get_fallback_languages,
|
||||
get_language_list,
|
||||
get_public_languages,
|
||||
get_redirect_on_fallback,
|
||||
is_language_prefix_patterns_used,
|
||||
)
|
||||
from cms.utils.page import get_page_from_request
|
||||
from cms.utils.page_permissions import user_can_change_page
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@ from django.core.exceptions import ImproperlyConfigured
|
|||
from django.forms.models import ModelForm
|
||||
from django.utils.encoding import force_str
|
||||
from django.utils.functional import cached_property
|
||||
from django.utils.translation import gettext as _, override as force_language
|
||||
from django.utils.translation import gettext as _
|
||||
from django.utils.translation import override as force_language
|
||||
|
||||
from cms.utils.conf import get_cms_setting
|
||||
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ class WizardPool:
|
|||
"""
|
||||
self._discover()
|
||||
return [value for (key, value) in sorted(
|
||||
self._entries.items(), key=lambda e: getattr(e[1], 'weight'))]
|
||||
self._entries.items(), key=lambda e: e[1].weight)]
|
||||
|
||||
|
||||
wizard_pool = WizardPool()
|
||||
|
|
|
|||
19
pyproject.toml
Normal file
19
pyproject.toml
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
[tool.ruff]
|
||||
exclude = [
|
||||
".env",
|
||||
".venv",
|
||||
"**/migrations/**",
|
||||
]
|
||||
ignore = [
|
||||
"E501", # line too long
|
||||
"F403", # 'from module import *' used; unable to detect undefined names
|
||||
"E701", # multiple statements on one line (colon)
|
||||
"F401", # module imported but unused
|
||||
]
|
||||
line-length = 119
|
||||
select = [
|
||||
"I",
|
||||
"E",
|
||||
"F",
|
||||
"W",
|
||||
]
|
||||
Loading…
Reference in New Issue
Block a user