fix: delete media (#1366)

This commit is contained in:
Markos Gogoulos 2025-09-01 20:06:49 +03:00 committed by GitHub
parent 817e16ac60
commit 7a1b32f1ba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 27 additions and 6 deletions

View File

@ -124,7 +124,9 @@ migrations_1 | Created admin user with password: gwg1clfkwf
or if you have set the ADMIN_PASSWORD variable on docker-compose file you have used (example `docker-compose.yaml`), that variable will be set as the admin user's password
`Note`: if you want to use the automatic transcriptions, run `docker-compose -f docker-compose.yaml -f docker-compose.full.yaml up` instead, as this is using a separate image.
`Note`: if you want to use the automatic transcriptions, you have to do one of the following:
* either use the docker-compose.full.yaml, so in this case run `docker-compose -f docker-compose.yaml -f docker-compose.full.yaml up`
* or edit the docker-compose.yaml file and set the image for the celery_worker service as mediacms/mediacms:full instead of mediacms/mediacms:latest
### Update
@ -1008,7 +1010,7 @@ When the whisper transcribe task is triggered for a media file, MediaCMS runs th
### Configuration
Transcription functionality is available only for the Docker installation. To enable this feature, you must use the `docker-compose.full.yaml` file, as it contains an image with the necessary requirements.
Transcription functionality is available only for the Docker installation. To enable this feature, you must either use the `docker-compose.full.yaml` file, as it contains an image with the necessary requirements, or you can also set that celery_worker service is usine mediacms:full image instead of mediacms:latest.
By default, all users have the ability to send a request for a video to be transcribed, as well as transcribed and translated to English. If you wish to change this behavior, you can edit the `settings.py` file and set `USER_CAN_TRANSCRIBE_VIDEO=False`.

View File

@ -1,6 +1,6 @@
from crispy_forms.bootstrap import FormActions
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Field, Layout, Submit
from crispy_forms.layout import HTML, Field, Layout, Submit
from django import forms
from django.conf import settings
@ -241,6 +241,8 @@ class WhisperSubtitlesForm(forms.ModelForm):
self.fields['allow_whisper_transcribe_and_translate'].widget.attrs['readonly'] = True
self.fields['allow_whisper_transcribe_and_translate'].widget.attrs['disabled'] = True
both_readonly = self.instance.allow_whisper_transcribe and self.instance.allow_whisper_transcribe_and_translate
self.helper = FormHelper()
self.helper.form_tag = True
self.helper.form_class = 'post-form'
@ -252,7 +254,13 @@ class WhisperSubtitlesForm(forms.ModelForm):
CustomField('allow_whisper_transcribe_and_translate'),
)
self.helper.layout.append(FormActions(Submit('submit_whisper', 'Submit', css_class='primaryAction')))
if not both_readonly:
self.helper.layout.append(FormActions(Submit('submit_whisper', 'Submit', css_class='primaryAction')))
else:
# Optional: Add a disabled button with explanatory text
self.helper.layout.append(
FormActions(Submit('submit_whisper', 'Submit', css_class='primaryAction', disabled=True), HTML('<small class="text-muted">Cannot submit - both options are already enabled</small>'))
)
def clean_allow_whisper_transcribe(self):
# Ensure the field value doesn't change if it was originally True

View File

@ -235,6 +235,8 @@ class Media(models.Model):
self.__original_media_file = self.media_file
self.__original_thumbnail_time = self.thumbnail_time
self.__original_uploaded_poster = self.uploaded_poster
self.__original_allow_whisper_transcribe = self.allow_whisper_transcribe
self.__original_allow_whisper_transcribe_and_translate = self.allow_whisper_transcribe_and_translate
def save(self, *args, **kwargs):
if not self.title:
@ -275,6 +277,17 @@ class Media(models.Model):
if self.thumbnail_time != self.__original_thumbnail_time:
self.__original_thumbnail_time = self.thumbnail_time
self.set_thumbnail(force=True)
transcription_changed = (
self.allow_whisper_transcribe != self.__original_allow_whisper_transcribe or self.allow_whisper_transcribe_and_translate != self.__original_allow_whisper_transcribe_and_translate
)
if transcription_changed and self.media_type == "video":
self.transcribe_function()
# Update the original values for next comparison
self.__original_allow_whisper_transcribe = self.allow_whisper_transcribe
self.__original_allow_whisper_transcribe_and_translate = self.allow_whisper_transcribe_and_translate
else:
# media is going to be created now
# after media is saved, post_save signal will call media_init function
@ -989,8 +1002,6 @@ def media_save(sender, instance, created, **kwargs):
tag.update_tag_media()
instance.update_search_vector()
if instance.media_type == "video":
instance.transcribe_function()
@receiver(pre_delete, sender=Media)