text = chunk.at_revision(version).materialize()
else:
text = chunk.materialize()
- materials = set(os.listdir(os.path.join(settings.MEDIA_ROOT, settings.IMAGE_DIR, chunk.book.gallery)))
+ gallery_dir = os.path.join(settings.MEDIA_ROOT, settings.IMAGE_DIR, chunk.book.gallery)
+ materials = set(os.listdir(gallery_dir)) if os.path.isdir(gallery_dir) else []
materials.update([n.rsplit('.', 1)[0] for n in materials])
return render(request, template_name, {
'serialized_document_data': json.dumps({