Skip to content

Commit

Permalink
Ad deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
zerolab committed Apr 23, 2023
1 parent 7fede7b commit fe3772c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/wagtailmedia/deprecation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class RemovedInWagtailMedia012Warning(PendingDeprecationWarning):
class RemovedInWagtailMedia014Warning(PendingDeprecationWarning):
pass


class RemovedInWagtailMedia013Warning(DeprecationWarning):
class RemovedInWagtailMedia015Warning(DeprecationWarning):
pass
22 changes: 22 additions & 0 deletions src/wagtailmedia/edit_handlers.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
Expand Down

0 comments on commit fe3772c

Please sign in to comment.