add committing, too
[wolnelektury.git] / apps / api / models.py
index 22e5648..20dd129 100644 (file)
@@ -5,12 +5,14 @@
 from django.contrib.contenttypes.models import ContentType
 from django.db import models
 from django.db.models.signals import pre_delete
 from django.contrib.contenttypes.models import ContentType
 from django.db import models
 from django.db.models.signals import pre_delete
+from django.utils.translation import ugettext_lazy as _
 
 from catalogue.models import Book, Tag
 
 
 class Deleted(models.Model):
     object_id = models.IntegerField()
 
 from catalogue.models import Book, Tag
 
 
 class Deleted(models.Model):
     object_id = models.IntegerField()
+    slug = models.SlugField(_('slug'), max_length=120, blank=True, db_index=True)
     content_type = models.ForeignKey(ContentType)
     category = models.CharField(max_length=64, null=True, blank=True, db_index=True)
     created_at = models.DateTimeField(editable=False, db_index=True)
     content_type = models.ForeignKey(ContentType)
     category = models.CharField(max_length=64, null=True, blank=True, db_index=True)
     created_at = models.DateTimeField(editable=False, db_index=True)
@@ -31,6 +33,7 @@ def _pre_delete_handler(sender, instance, **kwargs):
                 category = instance.category
         else:
             category = None
                 category = instance.category
         else:
             category = None
-        Deleted.objects.create(type=sender, object_id=instance.id, 
-            created_at=instance.created_at, category=category)
+        content_type = ContentType.objects.get_for_model(sender)
+        Deleted.objects.create(content_type=content_type, object_id=instance.id, 
+            created_at=instance.created_at, category=category, slug=instance.slug)
 pre_delete.connect(_pre_delete_handler)
 pre_delete.connect(_pre_delete_handler)