Skip to content

Commit

Permalink
fix: remove delete_published_thumbnail and use existing `delete_thu…
Browse files Browse the repository at this point in the history
…mbnails` method to remove thumbnail images.
  • Loading branch information
joshyu committed Mar 4, 2024
1 parent e47b7f0 commit 4e53f3f
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions djangocms_versioning_filer/cms_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,16 @@
FilerContentConfig = None


def delete_published_thumbnail(file_obj):
#delete published thumbnail image
path, source_filename = os.path.split(file_obj.name)
subdir = file_obj.thumbnail_subdir
thumbnail_prefix = os.path.join(path, subdir, source_filename)
thumbnail_source = thumbnail_models.Source.objects.filter(name__icontains=thumbnail_prefix).first()
if thumbnail_source:
for thumbnail_cache in thumbnail_source.thumbnails.all():
thumbnail_cache.delete()


def on_file_publish(version):
file_content = version.content
file_content._file_data_changed_hint = False
file_content.file = move_file(file_content, get_published_file_path(file_content))
file_content.save()

if type(file_content) == Image:
delete_published_thumbnail(file_content.file)
file_content.is_public = not file_content.is_public
file_content.file.delete_thumbnails()
file_content.is_public = not file_content.is_public


def on_file_unpublish(version):
Expand All @@ -59,7 +50,9 @@ def on_file_unpublish(version):
file_content.save()

if type(file_content) == Image:
delete_published_thumbnail(file_content.file)
file_content.is_public = not file_content.is_public
file_content.file.delete_thumbnails()
file_content.is_public = not file_content.is_public


def versioning_filer_models_config():
Expand Down

0 comments on commit 4e53f3f

Please sign in to comment.