Changeset 140:775c9f90987e


Ignore:
Timestamp:
03/08/10 20:11:34 (3 years ago)
Author:
Diego Mascialino <dmascialino@…>
Branch:
default
Parents:
139:d6ffc8e4169d (diff), 138:3bf7566e6d80 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

merge

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • cyclope/models.py

    r138 r140  
    274274        return '/%s/%s/' % (self._meta.object_name.lower(), self.slug) 
    275275 
     276    @classmethod 
     277    def get_app_label(cls): 
     278        return cls._meta.app_label 
     279 
     280    @classmethod 
     281    def get_object_name(cls): 
     282        return cls._meta.object_name.lower() 
     283 
    276284    def __unicode__(self): 
    277285        return self.name 
  • cyclope/models.py

    r139 r140  
    245245                                               object_id_field='self_id', 
    246246                                               content_type_field='self_type') 
    247  
    248     def delete(self, using=None): 
    249         # the cascade delete does not delete the RelatedContent elements 
    250         # 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  
    258247    def pictures(self): 
    259248        if self.related_contents: 
  • cyclope/settings.py

    r138 r140  
    3030from cyclope.models import SiteSettings 
    3131 
     32from cyclope.core.frontend.sites import site 
    3233 
    3334settings.TEMPLATE_DIRS += (os.path.join(os.path.dirname(__file__), 'templates'),) 
     
    7071 
    7172    return site_settings 
     73 
     74CYCLOPE_BASE_CONTENT_TYPES = site.base_content_types 
    7275 
    7376CYCLOPE_SITE_SETTINGS = get_site_settings() 
  • cyclope/settings.py

    r139 r140  
    2626from django.conf import settings 
    2727from django.utils.translation import ugettext_lazy as _ 
    28 from django.db.models.signals import post_save 
     28from django.db.models.signals import post_save, pre_delete 
    2929 
    3030from cyclope.models import SiteSettings 
     
    110110 
    111111post_save.connect(_refresh_site_settings, sender=SiteSettings) 
     112 
     113from django.contrib.contenttypes.models import ContentType 
     114from cyclope.models import RelatedContent 
     115 
     116def _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 
     127pre_delete.connect(_delete_related_contents) 
Note: See TracChangeset for help on using the changeset viewer.