Changes in [139:d6ffc8e4169d:140:775c9f90987e]
- Files:
-
- 3 edited
-
cyclope/models.py (modified) (1 diff)
-
cyclope/settings.py (modified) (2 diffs)
-
demo/cyclope_project/db/site.db (modified) (previous)
Legend:
- Unmodified
- Added
- Removed
-
cyclope/models.py
r139 r140 245 245 object_id_field='self_id', 246 246 content_type_field='self_type') 247 248 def delete(self, using=None):249 # the cascade delete does not delete the RelatedContent elements250 # where this object is the related content, so we do it here.251 ctype = ContentType.objects.get_for_model(self)252 related_from = RelatedContent.objects.filter(other_type=ctype,253 other_id=self.id)254 for obj in related_from:255 obj.delete()256 super(BaseContent, self).delete(using)257 258 247 def pictures(self): 259 248 if self.related_contents: -
cyclope/settings.py
r139 r140 26 26 from django.conf import settings 27 27 from django.utils.translation import ugettext_lazy as _ 28 from django.db.models.signals import post_save 28 from django.db.models.signals import post_save, pre_delete 29 29 30 30 from cyclope.models import SiteSettings … … 110 110 111 111 post_save.connect(_refresh_site_settings, sender=SiteSettings) 112 113 from django.contrib.contenttypes.models import ContentType 114 from cyclope.models import RelatedContent 115 116 def _delete_related_contents(sender, instance, **kwargs): 117 # the cascade delete does not delete the RelatedContent elements 118 # where this object is the related content, so we do it here. 119 ctype = ContentType.objects.get_for_model(sender) 120 if hasattr(instance, 'id'): 121 print "instance:", instance.id 122 related_from = RelatedContent.objects.filter(other_type=ctype, 123 other_id=instance.id) 124 for obj in related_from: 125 obj.delete() 126 127 pre_delete.connect(_delete_related_contents)
Note: See TracChangeset
for help on using the changeset viewer.

