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
bcf60cd0
Commit
bcf60cd0
authored
Aug 22, 2013
by
fred
Browse files
load-from-spip: set images for emissions & episodes
parent
2800de54
Changes
1
Hide whitespace changes
Inline
Side-by-side
panikdb/emissions/management/commands/load-from-spip.py
View file @
bcf60cd0
...
...
@@ -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
():
...
...
Write
Preview
Supports
Markdown
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