X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/357027375ff8867f42ca34bcbfb5a78b5b185fc3..1b80c204be885588f7cbe95610e3677f2f886801:/src/libraries/models.py diff --git a/src/libraries/models.py b/src/libraries/models.py index c83afbbba..3e80301e7 100644 --- a/src/libraries/models.py +++ b/src/libraries/models.py @@ -1,8 +1,8 @@ -# -*- 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.db import models +from django.urls import reverse from django.utils.translation import ugettext_lazy as _ @@ -16,30 +16,28 @@ class Catalog(models.Model): verbose_name = _('catalog') verbose_name_plural = _('catalogs') - def __unicode__(self): + def __str__(self): return self.name - @models.permalink def get_absolute_url(self): - return ('libraries_catalog_view', [self.slug]) + return reverse('libraries_catalog_view', args=[self.slug]) class Library(models.Model): """Represent a single library in the libraries dictionary""" - name = models.CharField(_('name'), max_length=120, blank=True) - slug = models.SlugField(_('slug'), max_length=120, unique=True, db_index=True, null=True) + name = models.CharField(_('name'), max_length=120, blank=True) + slug = models.SlugField(_('slug'), max_length=120, unique=True, db_index=True, null=True) catalog = models.ForeignKey(Catalog, null=False, related_name='libraries', on_delete=models.PROTECT) - url = models.CharField(_('url'), max_length=120, blank=True) + url = models.CharField(_('url'), max_length=120, blank=True) description = models.TextField(_('description'), blank=True) class Meta: verbose_name = _('library') verbose_name_plural = _('libraries') - def __unicode__(self): + def __str__(self): return self.name - @models.permalink def get_absolute_url(self): - return ('libraries_library_view', [self.catalog.slug, self.slug]) + return reverse('libraries_library_view', args=[self.catalog.slug, self.slug])