diff --git a/src/wagtailmedia/deprecation.py b/src/wagtailmedia/deprecation.py index a6dc666..471c455 100644 --- a/src/wagtailmedia/deprecation.py +++ b/src/wagtailmedia/deprecation.py @@ -1,6 +1,6 @@ -class RemovedInWagtailMedia012Warning(PendingDeprecationWarning): +class RemovedInWagtailMedia014Warning(PendingDeprecationWarning): pass -class RemovedInWagtailMedia013Warning(DeprecationWarning): +class RemovedInWagtailMedia015Warning(DeprecationWarning): pass diff --git a/src/wagtailmedia/edit_handlers.py b/src/wagtailmedia/edit_handlers.py index fd834b0..7486898 100644 --- a/src/wagtailmedia/edit_handlers.py +++ b/src/wagtailmedia/edit_handlers.py @@ -1,11 +1,13 @@ from __future__ import annotations +import warnings from typing import TYPE_CHECKING from django.template.loader import render_to_string from wagtail.admin.compare import ForeignObjectComparison from wagtail.admin.panels import FieldPanel +from .deprecation import RemovedInWagtailMedia015Warning from .models import MediaType from .utils import format_audio_html, format_video_html @@ -24,6 +26,26 @@ def __init__(self, field_name, media_type=None, *args, **kwargs): self.media_type = media_type + if self.media_type is None: + warnings.warn( + ( + "The `MediaChooserPanel` field panel is deprecated. " + "Please use the `FieldPanel()` instead." + ), + RemovedInWagtailMedia015Warning, + stacklevel=2, + ) + else: + warnings.warn( + ( + "The `MediaChooserPanel` field panel is deprecated. Please use the " + "specialised `AudioChooserPanel()` for audio only " + "and `VideoChooserPanel()` for video only." + ), + RemovedInWagtailMedia015Warning, + stacklevel=2, + ) + def clone_kwargs(self): kwargs = super().clone_kwargs() kwargs.update(media_type=self.media_type)