fnp
/
redakcja.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
error reporting
[redakcja.git]
/
apps
/
catalogue
/
models
/
document.py
diff --git
a/apps/catalogue/models/document.py
b/apps/catalogue/models/document.py
index
5fa6242
..
d58a4d1
100755
(executable)
--- a/
apps/catalogue/models/document.py
+++ b/
apps/catalogue/models/document.py
@@
-7,6
+7,7
@@
from __future__ import unicode_literals
from datetime import date
from django.conf import settings
from datetime import date
from django.conf import settings
+from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned
from django.db import models
from django.template.loader import render_to_string
from django.utils.translation import ugettext_lazy as _
from django.db import models
from django.template.loader import render_to_string
from django.utils.translation import ugettext_lazy as _
@@
-38,8
+39,7
@@
class Document(Ref):
def meta(self):
from lxml import etree
def meta(self):
from lxml import etree
- # Wrong! should be metadata
- d = {}
+ metadata = {}
data = self.materialize()
data = data.replace(u'\ufeff', '')
data = self.materialize()
data = data.replace(u'\ufeff', '')
@@
-53,8
+53,8
@@
class Document(Ref):
header = t.find('.//header')
if header is None:
header = etree.fromstring(data).find('.//{http://nowoczesnapolska.org.pl/sst#}header')
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 ' '
- #print 'meta', d['title']
+
metadata
['title'] = getattr(header, 'text', ' ') or ' '
+ #
print 'meta', d['title']
m = t.find('metadata')
if m is None:
m = t.find('metadata')
if m is None:
@@
-62,12
+62,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:
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:
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:
def can_edit(self, user):
if self.owner_user:
@@
-87,7
+87,7
@@
class Document(Ref):
def get_plan(self):
try:
plan = self.plan_set.get(stage=self.stage)
def get_plan(self):
try:
plan = self.plan_set.get(stage=self.stage)
- except:
+ except
(ObjectDoesNotExist, MultipleObjectsReturned)
:
return None
return plan
return None
return plan