Skip to content

Commit

Permalink
Update hooks, add RedirectMixin.admin_fieldset
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiask committed Oct 21, 2024
1 parent d38e34c commit 9716d2c
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 21 deletions.
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
@@ -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
},
Expand Down
11 changes: 11 additions & 0 deletions feincms3/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
28 changes: 15 additions & 13 deletions tests/testapp/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"]
Expand All @@ -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 = [
Expand Down

0 comments on commit 9716d2c

Please sign in to comment.