diff --git a/src/wagtailmedia/deprecation.py b/src/wagtailmedia/deprecation.py index b61831e..51a8588 100644 --- a/src/wagtailmedia/deprecation.py +++ b/src/wagtailmedia/deprecation.py @@ -1,6 +1,6 @@ -class RemovedInWagtailMedia015Warning(PendingDeprecationWarning): +class RemovedInWagtailMedia016Warning(PendingDeprecationWarning): pass -class RemovedInWagtailMedia016Warning(DeprecationWarning): +class RemovedInWagtailMedia017Warning(DeprecationWarning): pass diff --git a/src/wagtailmedia/edit_handlers.py b/src/wagtailmedia/edit_handlers.py index 77c07f4..096a3e4 100644 --- a/src/wagtailmedia/edit_handlers.py +++ b/src/wagtailmedia/edit_handlers.py @@ -1,11 +1,14 @@ 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 RemovedInWagtailMedia017Warning from .models import MediaType from .utils import format_audio_html, format_video_html from .widgets import AdminAudioChooser, AdminMediaChooser, AdminVideoChooser @@ -23,6 +26,26 @@ def __init__(self, field_name, *args, media_type=None, **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." + ), + RemovedInWagtailMedia017Warning, + stacklevel=2, + ) + else: + warnings.warn( + ( + "The `MediaChooserPanel` field panel is deprecated. Please use the " + "specialised `AudioChooserPanel()` for audio only " + "and `VideoChooserPanel()` for video only." + ), + RemovedInWagtailMedia017Warning, + stacklevel=2, + ) + def clone_kwargs(self): kwargs = super().clone_kwargs() kwargs.update(media_type=self.media_type) diff --git a/src/wagtailmedia/views/viewsets.py b/src/wagtailmedia/views/viewsets.py index 4acd73c..2529d0a 100644 --- a/src/wagtailmedia/views/viewsets.py +++ b/src/wagtailmedia/views/viewsets.py @@ -1,6 +1,5 @@ from django.utils.functional import cached_property from django.utils.translation import gettext_lazy as _ - from wagtail.admin.ui.tables import Column from wagtail.admin.views.generic.chooser import ( ChooseResultsView,