From 191d8ab10e436bafdeac529245d06e9f922646ff Mon Sep 17 00:00:00 2001 From: Ronny Vedrilla Date: Fri, 21 Jun 2024 13:40:20 +0200 Subject: [PATCH] v3.0.4 --- .../templates/snippets/content.tpl | 5 +- .../templates/snippets/installation.tpl | 5 +- .pre-commit-config.yaml | 8 +++ CHANGES.md | 3 ++ README.md | 54 +++++++++---------- django_dynamic_admin_forms/__init__.py | 2 +- pyproject.toml | 2 +- 7 files changed, 39 insertions(+), 40 deletions(-) diff --git a/.ambient-package-update/templates/snippets/content.tpl b/.ambient-package-update/templates/snippets/content.tpl index de2d6f2..b33671b 100644 --- a/.ambient-package-update/templates/snippets/content.tpl +++ b/.ambient-package-update/templates/snippets/content.tpl @@ -16,10 +16,8 @@ Add simple interactions to the otherwise static django admin. - Add the module to `INSTALLED_APPS`: ```python INSTALLED_APPS = ( - ..., 'django_dynamic_admin_forms', - 'django.contrib.admin' - ... + 'django.contrib.admin', ) ``` Ensure that the `dynamic_admin_forms` comes before the @@ -32,7 +30,6 @@ Add simple interactions to the otherwise static django admin. { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'APP_DIRS': True, - ... }, ] ``` diff --git a/.ambient-package-update/templates/snippets/installation.tpl b/.ambient-package-update/templates/snippets/installation.tpl index d4ef501..e8fa8a5 100644 --- a/.ambient-package-update/templates/snippets/installation.tpl +++ b/.ambient-package-update/templates/snippets/installation.tpl @@ -11,10 +11,8 @@ - Add the module to `INSTALLED_APPS`: ```python INSTALLED_APPS = ( - ..., 'django_dynamic_admin_forms', - 'django.contrib.admin' - ... + 'django.contrib.admin', ) ``` Ensure that the `dynamic_admin_forms` comes before the @@ -28,7 +26,6 @@ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'APP_DIRS': True, - ... }, ] ``` diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 947cd87..3225bdd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,6 +11,14 @@ repos: # Run the Ruff formatter. - id: ruff-format + - repo: https://github.com/adamchainz/blacken-docs + rev: 1.16.0 + hooks: + - id: blacken-docs + additional_dependencies: + - black==24.4.2 + files: '(?:README\.md|docs\/.*\.(?:md|rst))' + - repo: https://github.com/asottile/pyupgrade rev: v3.16.0 hooks: diff --git a/CHANGES.md b/CHANGES.md index 8967171..9879814 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,8 @@ # Changelog +**3.0.4** + * Linted docs with `blacken-docs` via `ambient-package-update` + **3.0.3** * Restructured Readme content diff --git a/README.md b/README.md index f0df353..0ee8e75 100644 --- a/README.md +++ b/README.md @@ -31,10 +31,8 @@ Add simple interactions to the otherwise static django admin. - Add the module to `INSTALLED_APPS`: ```python INSTALLED_APPS = ( - ..., - 'django_dynamic_admin_forms', - 'django.contrib.admin' - ... + "django_dynamic_admin_forms", + "django.contrib.admin", ) ``` Ensure that the `dynamic_admin_forms` comes before the @@ -45,9 +43,8 @@ Add simple interactions to the otherwise static django admin. ```python TEMPLATES = [ { - 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'APP_DIRS': True, - ... + "BACKEND": "django.template.backends.django.DjangoTemplates", + "APP_DIRS": True, }, ] ``` @@ -61,8 +58,8 @@ Add simple interactions to the otherwise static django admin. from django.urls import path, include urlpatterns = [ - path("admin/", admin.site.urls), - path("dynamic-admin-form/", include("django_dynamic_admin_forms.urls")), + path("admin/", admin.site.urls), + path("dynamic-admin-form/", include("django_dynamic_admin_forms.urls")), ] ``` - In addition to the standard `fields` declaration, specify a list of `dynamic_fields` @@ -83,20 +80,20 @@ Add simple interactions to the otherwise static django admin. @admin.register(MyModel) class MyModelAdmin(DynamicModelAdminMixin, admin.ModelAdmin): - fields = ("name", "city") - dynamic_fields = ("city",) - - def get_dynamic_city_field(self, data): - # automatically choose first city that matches first letter of name - name = data.get("name") - if not name: - queryset = City.objects.all() - value = data.get("city") - else: - queryset = City.objects.filter(name__startswith=name[0]) - value = queryset.first() - hidden = not queryset.exists() - return queryset, value, hidden + fields = ("name", "city") + dynamic_fields = ("city",) + + def get_dynamic_city_field(self, data): + # automatically choose first city that matches first letter of name + name = data.get("name") + if not name: + queryset = City.objects.all() + value = data.get("city") + else: + queryset = City.objects.filter(name__startswith=name[0]) + value = queryset.first() + hidden = not queryset.exists() + return queryset, value, hidden ``` @@ -155,10 +152,8 @@ $ yarn cypress # or npm run cypress - Add the module to `INSTALLED_APPS`: ```python INSTALLED_APPS = ( - ..., - 'django_dynamic_admin_forms', - 'django.contrib.admin' - ... + "django_dynamic_admin_forms", + "django.contrib.admin", ) ``` Ensure that the `dynamic_admin_forms` comes before the @@ -170,9 +165,8 @@ $ yarn cypress # or npm run cypress ```python TEMPLATES = [ { - 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'APP_DIRS': True, - ... + "BACKEND": "django.template.backends.django.DjangoTemplates", + "APP_DIRS": True, }, ] ``` diff --git a/django_dynamic_admin_forms/__init__.py b/django_dynamic_admin_forms/__init__.py index 78a77db..1cd2631 100644 --- a/django_dynamic_admin_forms/__init__.py +++ b/django_dynamic_admin_forms/__init__.py @@ -1,3 +1,3 @@ """Add simple dynamic interaction to the otherwise static django admin.""" -__version__ = "3.0.3" +__version__ = "3.0.4" diff --git a/pyproject.toml b/pyproject.toml index c1eba0e..001a244 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,7 +49,7 @@ dev = [ 'm2r2==0.3.3.post2', 'mistune<2.0.0', 'flit~=3.9', - 'ambient-package-update~=24.6.3', + 'ambient-package-update~=24.6.4', 'unittest-parametrize~=1.4', ]