from datetime import datetime
from django.db.models.signals import post_save, post_delete
+
class Author(models.Model):
name = models.CharField(_('name'), max_length=50, db_index=True)
slug = models.SlugField(_('slug'), max_length=120, db_index=True, unique=True)
def category(self):
return "author"
- def __unicode__(self):
+ def __str__(self):
return self.name
def __repr__(self):
@permalink
def get_absolute_url(self):
- return ('catalogue.views.tagged_object_list', [self.url_chunk])
+ return 'tagged_object_list', [self.url_chunk]
def has_description(self):
return len(self.description) > 0
verbose_name = _('book stub')
verbose_name_plural = _('book stubs')
- def __unicode__(self):
+ def __str__(self):
return self.title
@permalink
def get_absolute_url(self):
- return ('catalogue.views.book_detail', [self.slug])
+ return 'book_detail', [self.slug]
def in_pd(self):
return self.pd is not None and self.pd <= datetime.now().year
def update_index(sender, instance, **kwargs):
from search.index import Index
idx = Index()
- idx.index_tags(instance, remove_only=not 'created' in kwargs)
+ idx.index_tags(instance, remove_only='created' not in kwargs)
post_delete.connect(update_index, Author)
post_delete.connect(update_index, BookStub)