Skip to content

Commit c874591

Browse files
committed
Ad deprecation warnings
1 parent b6b321d commit c874591

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

src/wagtailmedia/deprecation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
class RemovedInWagtailMedia015Warning(PendingDeprecationWarning):
1+
class RemovedInWagtailMedia016Warning(PendingDeprecationWarning):
22
pass
33

44

5-
class RemovedInWagtailMedia016Warning(DeprecationWarning):
5+
class RemovedInWagtailMedia017Warning(DeprecationWarning):
66
pass

src/wagtailmedia/edit_handlers.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
from __future__ import annotations
22

3+
import warnings
34
from typing import TYPE_CHECKING
45

56
from django.template.loader import render_to_string
67
from wagtail.admin.compare import ForeignObjectComparison
78
from wagtail.admin.panels import FieldPanel
9+
from .deprecation import RemovedInWagtailMedia017Warning
810

911
from .models import MediaType
1012
from .utils import format_audio_html, format_video_html
@@ -23,6 +25,26 @@ def __init__(self, field_name, *args, media_type=None, **kwargs):
2325

2426
self.media_type = media_type
2527

28+
if self.media_type is None:
29+
warnings.warn(
30+
(
31+
"The `MediaChooserPanel` field panel is deprecated. "
32+
"Please use the `FieldPanel()` instead."
33+
),
34+
RemovedInWagtailMedia017Warning,
35+
stacklevel=2,
36+
)
37+
else:
38+
warnings.warn(
39+
(
40+
"The `MediaChooserPanel` field panel is deprecated. Please use the "
41+
"specialised `AudioChooserPanel()` for audio only "
42+
"and `VideoChooserPanel()` for video only."
43+
),
44+
RemovedInWagtailMedia017Warning,
45+
stacklevel=2,
46+
)
47+
2648
def clone_kwargs(self):
2749
kwargs = super().clone_kwargs()
2850
kwargs.update(media_type=self.media_type)

0 commit comments

Comments
 (0)