From 9716d2cad141fb30158e3746cf6ba06398475695 Mon Sep 17 00:00:00 2001 From: Matthias Kestenholz Date: Mon, 21 Oct 2024 17:37:37 +0200 Subject: [PATCH] Update hooks, add RedirectMixin.admin_fieldset --- .pre-commit-config.yaml | 14 +++++++------- CHANGELOG.rst | 2 ++ biome.json | 2 +- feincms3/mixins.py | 11 +++++++++++ pyproject.toml | 1 + tests/testapp/admin.py | 28 +++++++++++++++------------- 6 files changed, 37 insertions(+), 21 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 94c6bcd..1a1a7c5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ exclude: ".yarn/|yarn.lock|\\.min\\.(css|js)$" repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - id: check-added-large-files - id: check-builtin-literals @@ -14,27 +14,27 @@ repos: - id: mixed-line-ending - id: trailing-whitespace - repo: https://github.com/adamchainz/django-upgrade - rev: 1.21.0 + rev: 1.22.1 hooks: - id: django-upgrade args: [--target-version, "3.2"] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.6.4" + rev: "v0.7.0" hooks: - id: ruff args: [--unsafe-fixes] - id: ruff-format - repo: https://github.com/biomejs/pre-commit - rev: "v0.4.0" + rev: "v0.5.0" hooks: - id: biome-check - additional_dependencies: ["@biomejs/biome@1.8.3"] + additional_dependencies: ["@biomejs/biome@1.9.4"] args: [--unsafe] - repo: https://github.com/tox-dev/pyproject-fmt - rev: 2.2.3 + rev: 2.4.3 hooks: - id: pyproject-fmt - repo: https://github.com/abravalheri/validate-pyproject - rev: v0.19 + rev: v0.21 hooks: - id: validate-pyproject diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 10e8474..53b738f 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -13,6 +13,8 @@ Next version broadcast company). - Lifted the move status indicator above the nav sidebar. - Dropped compatibility with Python 3.9. +- Updated all pre-commit hooks. +- Added the ``RedirectMixin.admin_fieldset`` convenience method. 5.2 (2024-06-07) diff --git a/biome.json b/biome.json index 03bf2a0..dea25a7 100644 --- a/biome.json +++ b/biome.json @@ -1,5 +1,5 @@ { - "$schema": "https://biomejs.dev/schemas/1.8.3/schema.json", + "$schema": "https://biomejs.dev/schemas/1.9.4/schema.json", "organizeImports": { "enabled": false }, diff --git a/feincms3/mixins.py b/feincms3/mixins.py index 9d4fbbd..a09ae1d 100644 --- a/feincms3/mixins.py +++ b/feincms3/mixins.py @@ -304,3 +304,14 @@ def clean_fields(self, exclude=None): field="redirect_to_page", exclude=exclude, ) + + @classmethod + def admin_fieldset(cls, **kwargs): + cfg = { + "fields": ( + "redirect_to_page", + "redirect_to_url", + ), + "classes": ["tabbed"], + } | kwargs + return (_("Redirects"), cfg) diff --git a/pyproject.toml b/pyproject.toml index f8f2c78..184327a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,6 +24,7 @@ classifiers = [ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Topic :: Internet :: WWW/HTTP :: Dynamic Content", "Topic :: Software Development", "Topic :: Software Development :: Libraries :: Application Frameworks", diff --git a/tests/testapp/admin.py b/tests/testapp/admin.py index 68edb29..7f44627 100644 --- a/tests/testapp/admin.py +++ b/tests/testapp/admin.py @@ -3,6 +3,7 @@ from django.utils.text import capfirst from django.utils.translation import gettext_lazy as _ +from feincms3 import mixins from feincms3.admin import AncestorFilter, TreeAdmin from feincms3.plugins import external, html, image, richtext, snippet from testapp import models @@ -11,13 +12,13 @@ @admin.register(models.Page) class PageAdmin(ContentEditor, TreeAdmin): list_display = [ - "collapse_column", - "indented_title", - "move_column", + *TreeAdmin.list_display, "is_active", "menu", "language_code", "page_type", + "menu", + "optional", ] list_filter = ["is_active", "menu", AncestorFilter] list_editable = ["is_active"] @@ -30,23 +31,24 @@ class PageAdmin(ContentEditor, TreeAdmin): raw_id_fields = ["parent"] fieldsets = [ - (None, {"fields": ("is_active", "title", "parent")}), - ( - capfirst(_("path")), - {"fields": ("slug", "static_path", "path"), "classes": ("tabbed",)}, - ), ( - capfirst(_("settings")), + None, { "fields": ( + "is_active", + "title", + "parent", "menu", - "language_code", + ("language_code", "translation_of"), "page_type", - "optional", - ), - "classes": ("tabbed",), + ) }, ), + ( + capfirst(_("path")), + {"fields": ("slug", "static_path", "path"), "classes": ("tabbed",)}, + ), + mixins.RedirectMixin.admin_fieldset(), ] inlines = [