Commit bcf60cd0 authored by fred's avatar fred
Browse files

load-from-spip: set images for emissions & episodes

parent 2800de54
......@@ -220,6 +220,21 @@ class Command(BaseCommand):
documents=documents) or None
emission.text = makeHtmlFromSpip(rubric.texte,
documents=documents) or None
image_path = None
for ext in ('.jpg', '.png', '.gif'):
if os.path.exists('media/IMG/rubon%s%s' % (rubric.id_rubrique, ext)):
image_path = ['media/IMG/rubon%s%s' % (rubric.id_rubrique, ext)]
else:
if emission.text:
image_path = re.findall('src="/(media/IMG.*?)"', emission.text, re.DOTALL)
elif emission.description:
image_path = re.findall('src="/(media/IMG.*?)"', emission.description, re.DOTALL)
if image_path:
image_path = image_path[0]
emission.image = File(file(image_path))
emission.save()
emission.categories.clear()
for category in rubric.categories:
......@@ -243,6 +258,22 @@ class Command(BaseCommand):
documents=documents) or None
episode.text = makeHtmlFromSpip(article.texte,
documents=documents) or None
image_path = None
for ext in ('.jpg', '.png', '.gif'):
if os.path.exists('media/IMG/arton%s%s' % (article.id_article, ext)):
image_path = ['media/IMG/arton%s%s' % (article.id_article, ext)]
break
else:
if episode.text:
image_path = re.findall('src="/(media/IMG.*?)"', episode.text, re.DOTALL)
elif episode.description:
image_path = re.findall('src="/(media/IMG.*?)"', episode.description, re.DOTALL)
if image_path:
image_path = image_path[0]
episode.image = File(file(image_path))
episode.save()
if not Diffusion.objects.filter(episode=episode).count():
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment