Removing thumbnails on attachment deletion

remotes/origin/logger
Alejandro Alonso 2015-09-23 11:45:27 +02:00 committed by David Barragán Merino
parent ca6239eda2
commit 7d9f3914c0
3 changed files with 56 additions and 1 deletions

View File

@ -28,7 +28,7 @@ raven==5.1.1
bleach==1.4
django-ipware==0.1.0
premailer==2.8.1
django-transactional-cleanup==0.1.14
django-transactional-cleanup==0.1.15
lxml==3.4.1
git+https://github.com/Xof/django-pglocks.git@dbb8d7375066859f897604132bd437832d2014ea
pyjwkest==1.0.3

View File

@ -0,0 +1,17 @@
# Copyright (C) 2014 Andrey Antukh <niwi@niwi.be>
# Copyright (C) 2014 Jesús Espino <jespinog@gmail.com>
# Copyright (C) 2014 David Barragán <bameda@dbarragan.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
default_app_config = "taiga.projects.attachments.apps.AttachmentsAppConfig"

View File

@ -0,0 +1,38 @@
# Copyright (C) 2014 Andrey Antukh <niwi@niwi.be>
# Copyright (C) 2014 Jesús Espino <jespinog@gmail.com>
# Copyright (C) 2014 David Barragán <bameda@dbarragan.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from easy_thumbnails.files import get_thumbnailer
from django.apps import AppConfig
from django.apps import apps
from django_transactional_cleanup.signals import cleanup_post_delete
def thumbnail_delete(**kwargs):
thumbnailer = get_thumbnailer(kwargs["file"])
thumbnailer.delete_thumbnails()
def connect_attachment_signals():
cleanup_post_delete.connect(thumbnail_delete)
class AttachmentsAppConfig(AppConfig):
name = "taiga.projects.attachments"
verbose_name = "Attachments"
def ready(self):
connect_attachment_signals()