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 class Library(models.Model):
\r
20 """Represent a single library in the libraries dictionary"""
\r
22 name = models.CharField(_('name'), max_length = 120, blank = True)
23 catalog = models.ForeignKey(Catalog, null = False, related_name = 'libraries', on_delete = models.PROTECT)
\r
24 url = models.CharField(_('url'), max_length = 120, blank = True)
25 description = models.TextField(_('description'), blank = True)
\r
28 verbose_name = _('library')
\r
29 verbose_name_plural = _('libraries')
\r
31 def __unicode__(self):
\r
35 def get_absolute_url(self):
\r
36 return ('infopage', [self.slug])
\r