Commit 691abb0e authored by fred's avatar fred
Browse files

update slug of objects if necessary when loading from a spip dump file

parent 633d2d00
......@@ -323,14 +323,17 @@ class Command(BaseCommand):
def get_or_create_emission(self, rubric):
slug = rubric.url.lower()
try:
emission = Emission.objects.get(slug=slug)
except Emission.DoesNotExist:
slug = slug.split(',')[0]
possible_slugs = [rubric.url.lower(), rubric.url.lower().split(',')[0]]
for slug in possible_slugs:
try:
emission = Emission.objects.get(slug=slug)
break
except Emission.DoesNotExist:
emission = Emission()
continue
else:
emission = Emission()
emission.slug = possible_slugs[-1]
if emission.id and not self.do_updates:
return emission
......@@ -370,15 +373,20 @@ class Command(BaseCommand):
# not set it's probably not really an episode
return None
slug = article.url.lower()
if slug.startswith('nouvel-article'):
# <sigh/>
slug = slugify(unicode(article.titre))
try:
episode = Episode.objects.get(slug=slug)
except Episode.DoesNotExist:
possible_slugs = [article.url.lower()]
if article.url.lower().startswith('nouvel-article'):
possible_slugs.append(slugify(unicode(article.titre)))
for slug in possible_slugs:
try:
episode = Episode.objects.get(slug=slug)
break
except Episode.DoesNotExist:
continue
else:
episode = Episode()
episode.slug = slug
episode.slug = possible_slugs[-1]
if episode.id and not self.do_updates:
return episode
......
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