1 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
\r
2 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
\r
4 from django.db import models
\r
5 from django.urls import reverse
\r
8 class Catalog(models.Model):
\r
9 """Represents a dictionary of libraries"""
\r
11 name = models.CharField('nazwa', max_length=120, null=False)
\r
12 slug = models.SlugField('slug', max_length=120, unique=True, db_index=True)
\r
15 verbose_name = 'katalog'
\r
16 verbose_name_plural = 'katalogi'
\r
21 def get_absolute_url(self):
\r
22 return reverse('libraries_catalog_view', args=[self.slug])
\r
25 class Library(models.Model):
\r
26 """Represent a single library in the libraries dictionary"""
\r
28 name = models.CharField('nazwa', max_length=120, blank=True)
\r
29 slug = models.SlugField('slug', max_length=120, unique=True, db_index=True, null=True)
\r
30 catalog = models.ForeignKey(Catalog, null=False, related_name='libraries', on_delete=models.PROTECT)
\r
31 url = models.CharField('url', max_length=120, blank=True)
\r
32 description = models.TextField('opis', blank=True)
\r
35 verbose_name = 'biblioteka'
\r
36 verbose_name_plural = 'biblioteki'
\r
41 def get_absolute_url(self):
\r
42 return reverse('libraries_library_view', args=[self.catalog.slug, self.slug])
\r