Skip to content

Commit

Permalink
Add deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
zerolab committed Jun 17, 2024
1 parent b6b321d commit 6d2e8f2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 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 RemovedInWagtailMedia015Warning(PendingDeprecationWarning):
class RemovedInWagtailMedia016Warning(PendingDeprecationWarning):
pass


class RemovedInWagtailMedia016Warning(DeprecationWarning):
class RemovedInWagtailMedia017Warning(DeprecationWarning):
pass
23 changes: 23 additions & 0 deletions src/wagtailmedia/edit_handlers.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
Expand Down
1 change: 0 additions & 1 deletion src/wagtailmedia/views/viewsets.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down

0 comments on commit 6d2e8f2

Please sign in to comment.