2
0
Эх сурвалжийг харах

Formally deprecate StreamFieldPanel, BaseChooserPanel etc

Matt Westcott 3 жил өмнө
parent
commit
2a07990770

+ 1 - 1
docs/releases/2.17.md

@@ -105,7 +105,7 @@ As of this release, the use of special-purpose field panel types such as `Stream
  * If the panel provides a `widget_overrides` method, your code should instead call [`register_form_field_override`](/extending/forms) so that the desired widget is always selected for the relevant model field type.
  * If the panel provides a `get_comparison_class` method, your code should instead call `wagtail.admin.compare.register_comparison_class` to register the comparison class against the relevant model field type.
 
-If you do continue to use a custom panel class, note that the template context for panels derived from `BaseChooserPanel` has changed - the context variable `is_chosen`, and the variable name given by the panel's `object_type_name` property, are no longer available on the template. The only available variables are now `field` and `show_add_comment_button`. If your template depends on these additional variables, you will need to pass them explicitly by overriding the `render_as_field` method.
+If you do continue to use a custom panel class, note that the template context for panels derived from `BaseChooserPanel` has changed. `BaseChooserPanel` is deprecated and now functionally identical to `FieldPanel`; as a result, the context variable `is_chosen`, and the variable name given by the panel's `object_type_name` property, are no longer available on the template. The only available variables are now `field` and `show_add_comment_button`. If your template depends on these additional variables, you will need to pass them explicitly by overriding the `render_as_field` method.
 
 ### ModelAdmin forms must subclass `WagtailAdminModelForm`
 

+ 24 - 6
wagtail/admin/edit_handlers.py

@@ -1,5 +1,6 @@
 import functools
 import re
+from warnings import warn
 
 from django import forms
 from django.apps import apps
@@ -23,6 +24,7 @@ from wagtail.blocks import BlockField
 from wagtail.coreutils import camelcase_to_underscore
 from wagtail.models import COMMENTS_RELATION_NAME, Page
 from wagtail.utils.decorators import cached_classmethod
+from wagtail.utils.deprecation import RemovedInWagtail219Warning
 
 # DIRECT_FORM_FIELD_OVERRIDES, FORM_FIELD_OVERRIDES are imported for backwards
 # compatibility, as people are likely importing them from here and then
@@ -665,16 +667,26 @@ class FieldPanel(EditHandler):
 
 
 class RichTextFieldPanel(FieldPanel):
-    pass
+    def __init__(self, *args, **kwargs):
+        warn(
+            "wagtail.admin.edit_handlers.RichTextFieldPanel is obsolete and should be replaced by FieldPanel",
+            category=RemovedInWagtail219Warning,
+            stacklevel=2,
+        )
+        super().__init__(*args, **kwargs)
 
 
 class BaseChooserPanel(FieldPanel):
-    # For backwards compatibility only - chooser panels no longer need any base functionality
-    # beyond FieldPanel.
-    pass
+    def __init__(self, *args, **kwargs):
+        warn(
+            "wagtail.admin.edit_handlers.BaseChooserPanel is obsolete and should be replaced by FieldPanel",
+            category=RemovedInWagtail219Warning,
+            stacklevel=2,
+        )
+        super().__init__(*args, **kwargs)
 
 
-class PageChooserPanel(BaseChooserPanel):
+class PageChooserPanel(FieldPanel):
     def __init__(self, field_name, page_type=None, can_choose_root=False):
         super().__init__(field_name=field_name)
 
@@ -1059,4 +1071,10 @@ def reset_page_edit_handler_cache(**kwargs):
 
 
 class StreamFieldPanel(FieldPanel):
-    pass
+    def __init__(self, *args, **kwargs):
+        warn(
+            "wagtail.admin.edit_handlers.StreamFieldPanel is obsolete and should be replaced by FieldPanel",
+            category=RemovedInWagtail219Warning,
+            stacklevel=2,
+        )
+        super().__init__(*args, **kwargs)

+ 12 - 3
wagtail/documents/edit_handlers.py

@@ -1,5 +1,14 @@
-from wagtail.admin.edit_handlers import BaseChooserPanel
+from warnings import warn
 
+from wagtail.admin.edit_handlers import FieldPanel
+from wagtail.utils.deprecation import RemovedInWagtail219Warning
 
-class DocumentChooserPanel(BaseChooserPanel):
-    pass
+
+class DocumentChooserPanel(FieldPanel):
+    def __init__(self, *args, **kwargs):
+        warn(
+            "wagtail.documents.edit_handlers.DocumentChooserPanel is obsolete and should be replaced by wagtail.admin.edit_handlers.FieldPanel",
+            category=RemovedInWagtail219Warning,
+            stacklevel=2,
+        )
+        super().__init__(*args, **kwargs)

+ 12 - 3
wagtail/images/edit_handlers.py

@@ -1,11 +1,20 @@
+from warnings import warn
+
 from django.template.loader import render_to_string
 
 from wagtail.admin.compare import ForeignObjectComparison
-from wagtail.admin.edit_handlers import BaseChooserPanel
+from wagtail.admin.edit_handlers import FieldPanel
+from wagtail.utils.deprecation import RemovedInWagtail219Warning
 
 
-class ImageChooserPanel(BaseChooserPanel):
-    pass
+class ImageChooserPanel(FieldPanel):
+    def __init__(self, *args, **kwargs):
+        warn(
+            "wagtail.images.edit_handlers.ImageChooserPanel is obsolete and should be replaced by wagtail.admin.edit_handlers.FieldPanel",
+            category=RemovedInWagtail219Warning,
+            stacklevel=2,
+        )
+        super().__init__(*args, **kwargs)
 
 
 class ImageFieldComparison(ForeignObjectComparison):

+ 12 - 3
wagtail/snippets/edit_handlers.py

@@ -1,5 +1,14 @@
-from wagtail.admin.edit_handlers import BaseChooserPanel
+from warnings import warn
 
+from wagtail.admin.edit_handlers import FieldPanel
+from wagtail.utils.deprecation import RemovedInWagtail219Warning
 
-class SnippetChooserPanel(BaseChooserPanel):
-    pass
+
+class SnippetChooserPanel(FieldPanel):
+    def __init__(self, *args, **kwargs):
+        warn(
+            "wagtail.snippets.edit_handlers.SnippetChooserPanel is obsolete and should be replaced by wagtail.admin.edit_handlers.FieldPanel",
+            category=RemovedInWagtail219Warning,
+            stacklevel=2,
+        )
+        super().__init__(*args, **kwargs)