from django.core.cache import cache
from catalogue.utils import split_tags
from django.utils.safestring import mark_safe
-from librarian import dcparser
from slughifi import slughifi
from django.utils.translation import ugettext_lazy as _
verbose_name = _('picture')
verbose_name_plural = _('pictures')
- URLID_RE = r'[a-z0-9-]+'
- FILEID_RE = r'[a-z0-9-]+'
-
def save(self, force_insert=False, force_update=False, reset_short_html=True, **kwargs):
from sortify import sortify
@permalink
def get_absolute_url(self):
- return ('picture.views.picture_detail', [self.urlid()])
-
- def urlid(self):
- return self.slug
+ return ('picture.views.picture_detail', [self.slug])
@classmethod
def from_xml_file(cls, xml_file, image_file=None, overwrite=False):
"""
from sortify import sortify
from django.core.files import File
- from librarian.picture import WLPicture
+ from librarian.picture import WLPicture, ImageStore
close_xml_file = False
close_image_file = False
# class SimpleImageStore(object):
try:
# use librarian to parse meta-data
- picture_xml = WLPicture.from_file(xml_file)
+ picture_xml = WLPicture.from_file(xml_file,
+ image_store=ImageStore(picture_storage.path('images')))
# image_store=SimpleImageStore
picture, created = Picture.objects.get_or_create(slug=picture_xml.slug)
@property
def info(self):
if not hasattr(self, '_info'):
+ from librarian import dcparser
+ from librarian import picture
info = dcparser.parse(self.xml_file.path, picture.PictureInfo)
self._info = info
return self._info