Commit 4fad7613 authored by fred's avatar fred
Browse files

load tags from spip

parent fbd38d44
......@@ -117,6 +117,7 @@ class Command(BaseCommand):
setattr(article, attr, article_xml.find(attr).text)
if article.statut != 'publie':
continue
article.mots_cles = []
articles[article.id_article] = article
if rubrics[article.id_rubrique].id_parent != '2':
......@@ -201,6 +202,20 @@ class Command(BaseCommand):
c.save()
keyword.related_object = c
for articlekeyword_xml in root.iter('spip_mots_articles'):
keyword_id = articlekeyword_xml.find('id_mot').text
article_id = articlekeyword_xml.find('id_article').text
article = articles.get(article_id)
if not article:
continue
keyword = keywords.get(keyword_id)
if keyword is None:
continue
if keyword.id_groupe in ('10', '12'): # transversales & sujets
article.mots_cles.append(keyword.titre)
for emission_id in straight_emission_rubric_ids:
rubric = rubrics[emission_id]
slug = rubric.url.lower()
......@@ -274,6 +289,9 @@ class Command(BaseCommand):
image_path = image_path[0]
episode.image = File(file(image_path))
for motcle in article.mots_cles:
episode.tags.add(motcle.lower())
episode.save()
if not Diffusion.objects.filter(episode=episode).count():
......
Markdown is supported
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