Skip to content

Commit

Permalink
Merge pull request #105 from joshyu/fix/delete-thumbnail-when-publishing
Browse files Browse the repository at this point in the history
fix: delete published thumbnail image when publishing/unpublishing images
  • Loading branch information
FinalAngel committed Mar 5, 2024
2 parents 0b3790b + 4e53f3f commit 608ed41
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Changelog

Unreleased
==========
* fix: delete published thumbnail image when publishing/unpublishing images.

1.2.2 (2023-08-09)
==========
* fix: Filer admin to point correct change form template

1.2.1 (2022-11-14)
Expand Down
14 changes: 14 additions & 0 deletions djangocms_versioning_filer/cms_config.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
from functools import lru_cache

Check failure on line 1 in djangocms_versioning_filer/cms_config.py

View workflow job for this annotation

GitHub Actions / isort

Imports are incorrectly sorted and/or formatted.
import os

Check failure on line 2 in djangocms_versioning_filer/cms_config.py

View workflow job for this annotation

GitHub Actions / flake8

'os' imported but unused

from easy_thumbnails import models as thumbnail_models

Check failure on line 4 in djangocms_versioning_filer/cms_config.py

View workflow job for this annotation

GitHub Actions / flake8

'easy_thumbnails.models as thumbnail_models' imported but unused

from django.apps import apps
from django.conf import settings

from cms.app_base import CMSAppConfig, CMSAppExtension

import filer.settings
from filer.models import Image
from djangocms_versioning.datastructures import (
PolymorphicVersionableItem,
VersionableItemAlias,
Expand All @@ -28,6 +32,11 @@ def on_file_publish(version):
file_content._file_data_changed_hint = False
file_content.file = move_file(file_content, get_published_file_path(file_content))
file_content.save()

Check warning on line 35 in djangocms_versioning_filer/cms_config.py

View workflow job for this annotation

GitHub Actions / flake8

blank line contains whitespace
if type(file_content) == Image:

Check failure on line 36 in djangocms_versioning_filer/cms_config.py

View workflow job for this annotation

GitHub Actions / flake8

do not compare types, for exact checks use `is` / `is not`, for instance checks use `isinstance()`
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 @@ -39,6 +48,11 @@ def on_file_unpublish(version):
)
file_content.file = move_file(file_content, path)
file_content.save()

Check warning on line 51 in djangocms_versioning_filer/cms_config.py

View workflow job for this annotation

GitHub Actions / flake8

blank line contains whitespace
if type(file_content) == Image:

Check failure on line 52 in djangocms_versioning_filer/cms_config.py

View workflow job for this annotation

GitHub Actions / flake8

do not compare types, for exact checks use `is` / `is not`, for instance checks use `isinstance()`
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 608ed41

Please sign in to comment.