X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/b6d961cf3b454e6fcc9365a1121c34501f5f9106..80839825a00cc5dbbdd386e2b617df88bb47977e:/apps/catalogue/models/document.py diff --git a/apps/catalogue/models/document.py b/apps/catalogue/models/document.py index f190f5a0..9863e659 100755 --- a/apps/catalogue/models/document.py +++ b/apps/catalogue/models/document.py @@ -43,14 +43,16 @@ def metadata_from_text(text): if c is not None: metadata['cover_url'] = c.text for category in Category.objects.all(): - c = m.find('{http://purl.org/dc/elements/1.1/}' + category.dc_tag) - if c is not None: - if category.multiple: - if category.dc_tag not in metadata: - metadata[category.dc_tag] = [] - metadata[category.dc_tag].append(c.text) - else: - metadata[category.dc_tag] = c.text + for elem in m.findall('{http://purl.org/dc/elements/1.1/}' + category.dc_tag): + if elem.text is not None: + if category.multiple: + if category.dc_tag not in metadata: + metadata[category.dc_tag] = [] + metadata[category.dc_tag].append(elem.text) + else: + if category.dc_tag in metadata: + metadata['multiple_values'] = category.dc_tag + metadata[category.dc_tag] = elem.text return metadata @@ -72,6 +74,7 @@ class Document(Ref): class Meta: verbose_name = _('document') verbose_name_plural = _('documents') + ordering = ['-revision__created_at'] def short_html(self): return render_to_string('catalogue/book_list/book.html', {'book': self})