Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented and added media chooser into the edit translation workflow for audio and video files #847

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

catilgan-nextension
Copy link

Since the issue #587 still open, i tried to implement this missing feature. We needed this feature to translate the linked media files (Audio only) in our project as soon as possible.

Unfortunately, due to the missing deep knowledge in Wagtail module development process and time constraints, I've only implemented the necessary changes for this feature and skipped the unit tests. Furthermore, I couldn't test the video files, since we only need audio files in our project. I believe that the video files should work fine as well.

Copy link
Collaborator

@zerolab zerolab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for starting on this @catilgan-nextension
Had a quick look and left a few notes and suggestions.

This will need a few tests too.

@@ -82,6 +82,7 @@ basepython = python3.12
deps =
wagtail>=5.2,<6.3
Django>=4.2,<5.2
wagtailmedia>=0.0.0,<2.0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs to move to dev dependencies

@@ -53,6 +53,7 @@
window.chooserUrls = {
imageChooser: "{% url "wagtailimages_chooser:choose" %}",
documentChooser: "{% url "wagtaildocs_chooser:choose" %}",
mediaChooser: "{% url "wagtailmedia:chooser" %}",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make this work without the hard dependency, we'll need to move the chooserUrls logic to a template tag and conditionally add mediaChooser.

@@ -366,6 +367,9 @@ def widget_from_block(block, content_components=None):
elif isinstance(block, ImageChooserBlock):
return {"type": "image_chooser"}

elif isinstance(block, AudioChooserBlock) or isinstance(block, VideoChooserBlock):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrap in an if apps.is_installed("wagtail.embeds") and move the block imports inline

if apps.is_installed("wagtail.embeds"):

@@ -366,6 +367,9 @@ def widget_from_block(block, content_components=None):
elif isinstance(block, ImageChooserBlock):
return {"type": "image_chooser"}

elif isinstance(block, AudioChooserBlock) or isinstance(block, VideoChooserBlock):
return {"type": "media_chooser"}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, need to check whether the direct field (that is the ForeignKey) is to a media class and set the widget type for it as well in widget_from_field(), a la

elif issubclass(field.related_model, AbstractDocument):
return {"type": "document_chooser"}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants