1 # -*- coding: utf-8 -*-
2 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
3 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
5 from django.db import models
6 from django.utils.translation import ugettext_lazy as _
7 from django.core.urlresolvers import reverse
9 from catalogue.models import Book
12 class Cite(models.Model):
13 book = models.ForeignKey(Book)
14 text = models.TextField(_('text'))
15 small = models.BooleanField(_('small'), default=False, help_text=_('Make this cite display smaller.'))
16 vip = models.CharField(_('VIP'), max_length=128, null=True, blank=True)
17 link = models.URLField(_('link'))
20 ordering = ('vip', 'text')
22 def __unicode__(self):
23 return u"%s: %s…" % (self.vip, self.text[:60])
25 def get_absolute_url(self):
26 """This is used for testing."""
27 return "%s?choose_cite=%d" % (reverse('main_page'), self.id)