Commit c7425dcb authored by fred's avatar fred
Browse files

load-from-spip: remove old sound file before adding it again

parent 9497c469
...@@ -8,12 +8,14 @@ import urllib2 ...@@ -8,12 +8,14 @@ import urllib2
from optparse import make_option from optparse import make_option
from django.conf import settings
from django.core.files import File from django.core.files import File
from django.core.management.base import BaseCommand, CommandError from django.core.management.base import BaseCommand, CommandError
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.utils.text import slugify from django.utils.text import slugify
from ...models import Emission, Episode, Diffusion, Category, SoundFile, NewsItem from ...models import Emission, Episode, Diffusion, Category, SoundFile, NewsItem
from ...models import get_sound_path
from _spip2html import makeHtmlFromSpip from _spip2html import makeHtmlFromSpip
...@@ -445,6 +447,10 @@ class Command(BaseCommand): ...@@ -445,6 +447,10 @@ class Command(BaseCommand):
soundfile.podcastable = True soundfile.podcastable = True
soundfile.fragment = False soundfile.fragment = False
soundfile.title = episode_file.title or '[pas de titre]' soundfile.title = episode_file.title or '[pas de titre]'
sound_path = os.path.join(settings.MEDIA_ROOT,
get_sound_path(soundfile, episode_file.filename))
if os.path.exists(sound_path):
os.unlink(sound_path)
soundfile.file = File(file('media/IMG/' + episode_file.filename)) soundfile.file = File(file('media/IMG/' + episode_file.filename))
soundfile.save() soundfile.save()
......
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