Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
radiopanik
panikdb
Commits
a83f36f6
Commit
a83f36f6
authored
Aug 25, 2013
by
fred
Browse files
do not update image field is the filename is identical
parent
96d94674
Changes
1
Hide whitespace changes
Inline
Side-by-side
panikdb/emissions/management/commands/load-from-spip.py
View file @
a83f36f6
...
...
@@ -265,9 +265,7 @@ class Command(BaseCommand):
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
))
self
.
set_image
(
emission
,
image_path
)
emission
.
save
()
emission
.
categories
.
clear
()
...
...
@@ -304,9 +302,7 @@ class Command(BaseCommand):
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
))
self
.
set_image
(
episode
,
image_path
)
for
motcle
in
article
.
mots_cles
:
episode
.
tags
.
add
(
motcle
.
lower
())
...
...
@@ -341,19 +337,25 @@ class Command(BaseCommand):
soundfile
.
file
=
File
(
file
(
'media/IMG/'
+
episode_file
.
filename
))
soundfile
.
save
()
for
breve
in
breves
.
values
():
slug
=
breve
.
url
.
lower
()
try
:
newsitem
=
NewsItem
.
objects
.
get
(
slug
=
breve
.
url
.
lower
()
)
newsitem
=
NewsItem
.
objects
.
get
(
slug
=
slug
)
except
NewsItem
.
DoesNotExist
:
newsitem
=
NewsItem
()
newsitem
.
title
=
breve
.
titre
newsitem
.
slug
=
breve
.
url
.
lower
()
newsitem
.
slug
=
slug
newsitem
.
text
=
makeHtmlFromSpip
(
breve
.
texte
,
documents
=
documents
)
or
None
newsitem
.
datetime
=
datetime
.
strptime
(
breve
.
date_heure
,
'%Y-%m-%d %H:%M:%S'
)
image_path
=
re
.
findall
(
'src="/(media/IMG.*?)"'
,
newsitem
.
text
,
re
.
DOTALL
)
if
image_path
:
image_path
=
image_path
[
0
]
newsitem
.
image
=
File
(
file
(
image_path
))
self
.
set_image
(
newsitem
,
image_path
)
newsitem
.
save
()
def
set_image
(
self
,
object
,
image_path
):
if
not
image_path
:
return
image_path
=
image_path
[
0
]
if
object
.
image
and
os
.
path
.
basename
(
object
.
image
.
path
)
==
os
.
path
.
basename
(
image_path
):
return
object
.
image
=
File
(
file
(
image_path
))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment