diff --git a/src/wagtailmedia/blocks.py b/src/wagtailmedia/blocks.py index 8777649..1e85a27 100644 --- a/src/wagtailmedia/blocks.py +++ b/src/wagtailmedia/blocks.py @@ -1,4 +1,4 @@ -from typing import TYPE_CHECKING, Type +from typing import TYPE_CHECKING from django.forms import ModelChoiceField from django.template.loader import render_to_string @@ -52,7 +52,7 @@ def render_basic(self, value, context=None): f"You need to implement {self.__class__.__name__}.render_basic" ) - def get_comparison_class(self) -> Type["MediaChooserBlockComparison"]: + def get_comparison_class(self) -> type["MediaChooserBlockComparison"]: return MediaChooserBlockComparison diff --git a/src/wagtailmedia/wagtail_hooks.py b/src/wagtailmedia/wagtail_hooks.py index 47c6e41..e54a003 100644 --- a/src/wagtailmedia/wagtail_hooks.py +++ b/src/wagtailmedia/wagtail_hooks.py @@ -95,7 +95,7 @@ def register_media_permissions_panel(): def describe_collection_media(collection): media_count = get_media_model().objects.filter(collection=collection).count() if media_count: - url = reverse("wagtailmedia:index") + ("?collection_id=%d" % collection.id) + url = reverse("wagtailmedia:index") + f"?collection_id={collection.id}" return { "count": media_count, "count_text": ngettext( diff --git a/tests/test_admin.py b/tests/test_admin.py index 69e0501..7297b9f 100644 --- a/tests/test_admin.py +++ b/tests/test_admin.py @@ -2,6 +2,7 @@ from django.urls import reverse from wagtail.models import Page from wagtail.test.utils import WagtailTestUtils + from wagtailmedia.blocks import AbstractMediaChooserBlock diff --git a/tests/test_api.py b/tests/test_api.py index 3f19e32..0b3bb78 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -2,6 +2,7 @@ from django.test import TestCase, override_settings from django.urls import reverse + from wagtailmedia.models import get_media_model from .utils import create_audio, create_video @@ -66,8 +67,7 @@ def test_basic(self): # Check detail_url self.assertEqual( - item["meta"]["detail_url"], - "http://localhost/api/media/%d/" % item["id"], + item["meta"]["detail_url"], f"http://localhost/api/media/{item['id']}/" ) media = Media.objects.get(pk=item["id"]) diff --git a/tests/test_blocks.py b/tests/test_blocks.py index 02fc507..010ea34 100644 --- a/tests/test_blocks.py +++ b/tests/test_blocks.py @@ -1,6 +1,7 @@ from django.core.files.base import ContentFile from django.test import TestCase from django.urls import reverse + from wagtailmedia.blocks import ( AbstractMediaChooserBlock, AudioChooserBlock, diff --git a/tests/test_compare.py b/tests/test_compare.py index c10473d..0435f58 100644 --- a/tests/test_compare.py +++ b/tests/test_compare.py @@ -1,5 +1,7 @@ from django.test import TestCase from django.utils.safestring import SafeString + +from tests.testapp.models import BlogStreamPage from wagtailmedia.blocks import ( AudioChooserBlock, MediaChooserBlockComparison, @@ -9,8 +11,6 @@ from wagtailmedia.models import get_media_model from wagtailmedia.utils import format_audio_html, format_video_html -from tests.testapp.models import BlogStreamPage - from .utils import create_audio, create_video diff --git a/tests/test_edit_handlers.py b/tests/test_edit_handlers.py index ffc9e79..7e8752a 100644 --- a/tests/test_edit_handlers.py +++ b/tests/test_edit_handlers.py @@ -4,10 +4,10 @@ from wagtail import VERSION as WAGTAIL_VERSION from wagtail.admin.panels import FieldPanel, ObjectList from wagtail.models import Page -from wagtailmedia.edit_handlers import MediaChooserPanel, MediaFieldComparison -from wagtailmedia.widgets import AdminAudioChooser, AdminMediaChooser, AdminVideoChooser from tests.testapp.models import BlogStreamPage +from wagtailmedia.edit_handlers import MediaChooserPanel, MediaFieldComparison +from wagtailmedia.widgets import AdminAudioChooser, AdminMediaChooser, AdminVideoChooser from .utils import create_audio, create_video diff --git a/tests/test_form_override.py b/tests/test_form_override.py index 10f91c6..0477baf 100644 --- a/tests/test_form_override.py +++ b/tests/test_form_override.py @@ -1,10 +1,10 @@ from django import forms from django.test import TestCase, override_settings from wagtail.admin import widgets -from wagtailmedia import models -from wagtailmedia.forms import BaseMediaForm, get_media_base_form, get_media_form from tests.testapp.forms import AlternateMediaForm, OverridenWidget +from wagtailmedia import models +from wagtailmedia.forms import BaseMediaForm, get_media_base_form, get_media_form class TestFormOverride(TestCase): diff --git a/tests/test_models.py b/tests/test_models.py index 15790b1..d5f31a0 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -4,6 +4,7 @@ from django.db import transaction from django.template import Context, Template from django.test import TestCase, override_settings + from wagtailmedia.forms import get_media_form from wagtailmedia.models import get_media_model diff --git a/tests/test_permissions.py b/tests/test_permissions.py index 3dbf2f3..78af0d4 100644 --- a/tests/test_permissions.py +++ b/tests/test_permissions.py @@ -5,6 +5,7 @@ from django.urls import reverse from wagtail.models import Collection, GroupCollectionPermission from wagtail.test.utils import WagtailTestUtils + from wagtailmedia import models diff --git a/tests/test_settings.py b/tests/test_settings.py index 00a758d..4b424a8 100644 --- a/tests/test_settings.py +++ b/tests/test_settings.py @@ -1,6 +1,7 @@ from unittest import mock from django.test import TestCase, override_settings + from wagtailmedia.settings import WagtailMediaSettings, wagtailmedia_settings diff --git a/tests/test_tags.py b/tests/test_tags.py index 736c7b6..b8470fe 100644 --- a/tests/test_tags.py +++ b/tests/test_tags.py @@ -1,6 +1,7 @@ from unittest.mock import patch from django.test import TestCase + from wagtailmedia.templatetags.media_tags import wagtail_version_gte diff --git a/tests/test_utils.py b/tests/test_utils.py index ba9d800..eecdd0c 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -1,5 +1,6 @@ from django.core.files.base import ContentFile from django.test import TestCase + from wagtailmedia.models import get_media_model from wagtailmedia.utils import format_audio_html, format_video_html diff --git a/tests/test_views.py b/tests/test_views.py index d45da60..70b0b83 100644 --- a/tests/test_views.py +++ b/tests/test_views.py @@ -10,9 +10,9 @@ from django.urls import NoReverseMatch, reverse from wagtail.models import Collection, GroupCollectionPermission from wagtail.test.utils import WagtailTestUtils -from wagtailmedia import models from tests.testapp.models import EventPage, EventPageRelatedMedia +from wagtailmedia import models class TestMediaIndexView(TestCase, WagtailTestUtils): diff --git a/tests/test_widgets.py b/tests/test_widgets.py index 0ec6b2f..9de1aa0 100644 --- a/tests/test_widgets.py +++ b/tests/test_widgets.py @@ -1,5 +1,6 @@ from django.test import TestCase from django.urls import reverse + from wagtailmedia import widgets from wagtailmedia.widgets import AdminAudioChooser, AdminMediaChooser, AdminVideoChooser diff --git a/tests/testapp/forms.py b/tests/testapp/forms.py index 574a416..f27166a 100644 --- a/tests/testapp/forms.py +++ b/tests/testapp/forms.py @@ -1,4 +1,5 @@ from django.forms.widgets import Widget + from wagtailmedia.forms import BaseMediaForm diff --git a/tests/testapp/migrations/0001_initial.py b/tests/testapp/migrations/0001_initial.py index e95c7b4..4eb2ad0 100644 --- a/tests/testapp/migrations/0001_initial.py +++ b/tests/testapp/migrations/0001_initial.py @@ -7,11 +7,12 @@ import wagtail.blocks import wagtail.fields import wagtail.search.index -import wagtailmedia.blocks from django.conf import settings from django.db import migrations, models +import wagtailmedia.blocks + try: import wagtail.models.media as collections diff --git a/tests/testapp/models.py b/tests/testapp/models.py index dfd038b..2f5e5a8 100644 --- a/tests/testapp/models.py +++ b/tests/testapp/models.py @@ -6,6 +6,7 @@ from wagtail.admin.panels import FieldPanel, InlinePanel from wagtail.fields import RichTextField, StreamField from wagtail.models import Orderable, Page + from wagtailmedia.blocks import ( AbstractMediaChooserBlock, AudioChooserBlock, diff --git a/tests/urls.py b/tests/urls.py index bc77bd9..89641eb 100644 --- a/tests/urls.py +++ b/tests/urls.py @@ -5,6 +5,7 @@ from wagtail.admin import urls as wagtailadmin_urls from wagtail.api.v2.router import WagtailAPIRouter from wagtail.documents import urls as wagtaildocs_urls + from wagtailmedia.api.views import MediaAPIViewSet diff --git a/tests/utils.py b/tests/utils.py index e5885c5..a479917 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -3,6 +3,7 @@ from typing import Optional from django.core.files.base import ContentFile + from wagtailmedia.models import MediaType, get_media_model