aboutsummaryrefslogtreecommitdiffstats
path: root/account/models.py
diff options
context:
space:
mode:
authorWeitian LI <liweitianux@gmail.com>2014-04-28 13:40:19 +0800
committerWeitian LI <liweitianux@gmail.com>2014-04-28 13:40:19 +0800
commit04fd0429233bd15fe3cf046cef578d593778c12d (patch)
treeeac85f3ca32b501bb34721ca9da3f83f89ade5c9 /account/models.py
parent7ba3812f918983a47cda678c31d12e0cd089677a (diff)
downloaddjango-skaschool-04fd0429233bd15fe3cf046cef578d593778c12d.tar.bz2
* included archive urls
* moved 'file_cleanup' function to extra.py
Diffstat (limited to 'account/models.py')
-rw-r--r--account/models.py17
1 files changed, 1 insertions, 16 deletions
diff --git a/account/models.py b/account/models.py
index b42a8d1..9c3f44e 100644
--- a/account/models.py
+++ b/account/models.py
@@ -14,7 +14,7 @@ from django.utils.translation import ugettext_lazy as _
from django.db.models.signals import pre_delete
from registration.signals import user_registered, user_activated
-from account.extra import ContentTypeRestrictedFileField, OverwriteStorage
+from account.extra import ContentTypeRestrictedFileField, OverwriteStorage, file_cleanup
import os
@@ -251,21 +251,6 @@ def login_on_activation(sender, user, request, **kwargs):
user_activated.connect(login_on_activation)
-### delete files associated with model FileField
-# Pre-delete signal function for deleting files a model
-# https://djangosnippets.org/snippets/2820/
-def file_cleanup(sender, instance, *args, **kwargs):
- """
- Deletes the file(s) associated with a model instance. The model
- is not saved after deletion of the file(s) since this is meant
- to be used with the pre_delete signal.
- """
- for field_name, _ in instance.__dict__.iteritems():
- field = getattr(instance, field_name)
- if (issubclass(field.__class__, FieldFile) and field.name):
- # pass False so FileField does not save the model
- field.delete(save=False)
-
### connect to signal and sender
pre_delete.connect(file_cleanup, sender=UserProfile)
pre_delete.connect(file_cleanup, sender=UserFile)