1 from django.db import models
\r
2 from django.utils.translation import ugettext_lazy as _
\r
5 class Catalog(models.Model):
\r
6 """Represents a dictionary of libraries"""
\r
8 name = models.CharField(_('name'), max_length = 120, null = False)
\r
9 slug = models.SlugField(_('slug'), max_length = 120, unique = True, db_index = True)
\r
12 verbose_name = _('catalog')
\r
13 verbose_name_plural = _('catalogs')
\r
15 def __unicode__(self):
\r
19 def get_absolute_url(self):
\r
20 return ('libraries_catalog_view', [self.slug])
\r
23 class Library(models.Model):
\r
24 """Represent a single library in the libraries dictionary"""
\r
26 name = models.CharField(_('name'), max_length = 120, blank = True)
27 slug = models.SlugField(_('slug'), max_length = 120, unique = True, db_index = True, null = True)
28 catalog = models.ForeignKey(Catalog, null = False, related_name = 'libraries', on_delete = models.PROTECT)
\r
29 url = models.CharField(_('url'), max_length = 120, blank = True)
30 description = models.TextField(_('description'), blank = True)
\r
33 verbose_name = _('library')
\r
34 verbose_name_plural = _('libraries')
\r
36 def __unicode__(self):
\r
40 def get_absolute_url(self):
\r
41 return ('libraries_library_view', [self.catalog.slug, self.slug])