X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/2f9cb34a07fcd98effda2fa900e48c31813f14c8..db06ae78aac8e159e731524fc8588e7ad6945e20:/apps/catalogue/models/document.py diff --git a/apps/catalogue/models/document.py b/apps/catalogue/models/document.py index aedbb687..70f50f25 100755 --- a/apps/catalogue/models/document.py +++ b/apps/catalogue/models/document.py @@ -13,6 +13,7 @@ from django.utils.translation import ugettext_lazy as _ from dvcs.models import Ref from organizations.models import Organization from catalogue.constants import STAGES +from .tag import Tag class Document(Ref): @@ -23,6 +24,7 @@ class Document(Ref): stage = models.CharField(_('stage'), max_length=128, blank=True, default=STAGES[0]) assigned_to = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, related_name='assignments') deleted = models.BooleanField(default=False) + tags = models.ManyToManyField(Tag) # Where to cache searchable stuff from metadata? # Probably in some kind of search index. @@ -36,8 +38,7 @@ class Document(Ref): def meta(self): from lxml import etree - # Wrong! should be metadata - d = {} + metadata = {} data = self.materialize() data = data.replace(u'\ufeff', '') @@ -51,7 +52,7 @@ class Document(Ref): header = t.find('.//header') if header is None: header = etree.fromstring(data).find('.//{http://nowoczesnapolska.org.pl/sst#}header') - d['title'] = getattr(header, 'text', ' ') or ' ' + metadata['title'] = getattr(header, 'text', ' ') or ' ' #print 'meta', d['title'] m = t.find('metadata') @@ -60,12 +61,12 @@ class Document(Ref): if m is not None: c = m.find('{http://purl.org/dc/elements/1.1/}relation.coverimage.url') if c is not None: - d['cover_url'] = c.text + metadata['cover_url'] = c.text c = m.find('{http://purl.org/dc/elements/1.1/}audience') if c is not None: - d['audience'] = c.text + metadata['audience'] = c.text - return d + return metadata def can_edit(self, user): if self.owner_user: