X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/357027375ff8867f42ca34bcbfb5a78b5b185fc3..bde2a16ae2669bea94ec0f23c60213a26d4881f4:/src/pdcounter/models.py diff --git a/src/pdcounter/models.py b/src/pdcounter/models.py index 7c10f1e59..3ce7f72ce 100644 --- a/src/pdcounter/models.py +++ b/src/pdcounter/models.py @@ -1,20 +1,20 @@ -# -*- coding: utf-8 -*- # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later. # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # from django.conf import settings from django.db import models -from django.db.models import permalink -from django.utils.translation import ugettext_lazy as _ +from django.urls import reverse +from django.utils.translation import gettext_lazy as _ 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) sort_key = models.CharField(_('sort key'), max_length=120, db_index=True) description = models.TextField(_('description'), blank=True) - death = models.IntegerField(_(u'year of death'), blank=True, null=True) + death = models.IntegerField(_('year of death'), blank=True, null=True) gazeta_link = models.CharField(blank=True, max_length=240) wiki_link = models.CharField(blank=True, max_length=240) @@ -27,15 +27,14 @@ class Author(models.Model): def category(self): return "author" - def __unicode__(self): + def __str__(self): return self.name def __repr__(self): return "Author(slug=%r)" % self.slug - @permalink def get_absolute_url(self): - return ('catalogue.views.tagged_object_list', [self.url_chunk]) + return reverse('tagged_object_list', args=[self.url_chunk]) def has_description(self): return len(self.description) > 0 @@ -70,12 +69,11 @@ class BookStub(models.Model): 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 reverse('book_detail', args=[self.slug]) def in_pd(self): return self.pd is not None and self.pd <= datetime.now().year @@ -92,7 +90,7 @@ if not settings.NO_SEARCH_INDEX: 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)