Commit 2c449d15 authored by fred's avatar fred

use rich text for text fields (via ckeditor); convert spip to html

parent 226902c3
This diff is collapsed.
...@@ -2,12 +2,14 @@ from datetime import datetime ...@@ -2,12 +2,14 @@ from datetime import datetime
import gzip import gzip
import xml.etree.ElementTree as ET import xml.etree.ElementTree as ET
from django.core.management.base import BaseCommand, CommandError from django.core.management.base import BaseCommand, CommandError
from panikdb.emissions.models import Emission, Episode, Diffusion from panikdb.emissions.models import Emission, Episode, Diffusion
from _spip2html import makeHtmlFromSpip
class Rubric(object): class Rubric(object):
def __init__(self): def __init__(self):
self.articles = {} self.articles = {}
...@@ -87,7 +89,7 @@ class Command(BaseCommand): ...@@ -87,7 +89,7 @@ class Command(BaseCommand):
emission = Emission() emission = Emission()
emission.slug = slug emission.slug = slug
emission.title = rubric.titre emission.title = rubric.titre
emission.description = rubric.texte emission.description = makeHtmlFromSpip(rubric.texte)
emission.save() emission.save()
for article in rubric.articles.values(): for article in rubric.articles.values():
...@@ -95,11 +97,7 @@ class Command(BaseCommand): ...@@ -95,11 +97,7 @@ class Command(BaseCommand):
# date_redac was used for the diffusion date, if it's # date_redac was used for the diffusion date, if it's
# not set it's probably not really an episode # not set it's probably not really an episode
continue continue
try: slug = article.url.lower()
slug = article.url.lower()
except AttributeError:
print 'no slug for article', article.titre
slug = article.id_article
try: try:
episode = Episode.objects.get(slug=slug) episode = Episode.objects.get(slug=slug)
except Episode.DoesNotExist: except Episode.DoesNotExist:
...@@ -107,7 +105,7 @@ class Command(BaseCommand): ...@@ -107,7 +105,7 @@ class Command(BaseCommand):
episode.slug = slug episode.slug = slug
episode.emission = emission episode.emission = emission
episode.title = article.titre episode.title = article.titre
episode.description = article.texte episode.description = makeHtmlFromSpip(article.texte)
episode.save() episode.save()
if not Diffusion.objects.filter(episode=episode).count(): if not Diffusion.objects.filter(episode=episode).count():
......
...@@ -4,12 +4,13 @@ from django.core.urlresolvers import reverse ...@@ -4,12 +4,13 @@ from django.core.urlresolvers import reverse
from django.db import models from django.db import models
from ckeditor.fields import RichTextField
class Emission(models.Model): class Emission(models.Model):
title = models.CharField(max_length=50) title = models.CharField(max_length=50)
slug = models.SlugField() slug = models.SlugField()
description = models.TextField(null=True) description = RichTextField(null=True)
first_diffusion = models.DateTimeField(null=True) first_diffusion = models.DateTimeField(null=True)
# other_diffusions = # other_diffusions =
...@@ -22,7 +23,7 @@ class Episode(models.Model): ...@@ -22,7 +23,7 @@ class Episode(models.Model):
emission = models.ForeignKey('Emission', verbose_name=u'Emission') emission = models.ForeignKey('Emission', verbose_name=u'Emission')
title = models.CharField(max_length=50) title = models.CharField(max_length=50)
slug = models.SlugField() slug = models.SlugField()
description = models.TextField(null=True) description = RichTextField(null=True)
def __unicode__(self): def __unicode__(self):
return self.title return self.title
......
...@@ -5,9 +5,7 @@ ...@@ -5,9 +5,7 @@
<h2>{{ emission.title }}</h2> <h2>{{ emission.title }}</h2>
{% if emission.description %} {% if emission.description %}
<p> {{ emission.description|safe }}
{{ emission.description }}
</p>
{% endif %} {% endif %}
<h3>Épisodes</h3> <h3>Épisodes</h3>
......
{% extends "panikdb/base.html" %} {% extends "panikdb/base.html" %}
{% block extrascripts %}
<script src="{{ STATIC_URL }}ckeditor/ckeditor/ckeditor.js">
</script>
{% endblock %}
{% block content %} {% block content %}
<form method="post"> <form method="post">
<div id="form-content"> <div id="form-content">
......
...@@ -5,9 +5,7 @@ ...@@ -5,9 +5,7 @@
<h2>{{ episode.emission.title }} — {{ episode.title }}</h2> <h2>{{ episode.emission.title }} — {{ episode.title }}</h2>
{% if episode.description %} {% if episode.description %}
<p> {{ episode.description|safe }}
{{ episode.description }}
</p>
{% endif %} {% endif %}
<h3>Diffusions</h3> <h3>Diffusions</h3>
......
{% extends "panikdb/base.html" %} {% extends "panikdb/base.html" %}
{% block extrascripts %}
<script src="{{ STATIC_URL }}ckeditor/ckeditor/ckeditor.js">
</script>
{% endblock %}
{% block content %} {% block content %}
<h2>Nouvel épisode de « {{ emission.title }} »</h2> <h2>Nouvel épisode de « {{ emission.title }} »</h2>
......
...@@ -66,6 +66,8 @@ STATIC_ROOT = os.path.join(PROJECT_PATH, 'static') ...@@ -66,6 +66,8 @@ STATIC_ROOT = os.path.join(PROJECT_PATH, 'static')
# Example: "http://example.com/static/", "http://static.example.com/" # Example: "http://example.com/static/", "http://static.example.com/"
STATIC_URL = '/static/' STATIC_URL = '/static/'
CKEDITOR_UPLOAD_PATH = os.path.join(MEDIA_ROOT, 'uploads')
# Additional locations of static files # Additional locations of static files
STATICFILES_DIRS = ( STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static". # Put strings here, like "/home/html/static" or "C:/www/django/static".
...@@ -119,6 +121,7 @@ INSTALLED_APPS = ( ...@@ -119,6 +121,7 @@ INSTALLED_APPS = (
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'django.contrib.admin', 'django.contrib.admin',
'ckeditor',
'panikdb.emissions', 'panikdb.emissions',
) )
...@@ -151,6 +154,13 @@ LOGGING = { ...@@ -151,6 +154,13 @@ LOGGING = {
} }
} }
CKEDITOR_CONFIGS = {
'default': {
'toolbar': 'Basic',
},
}
try: try:
from local_settings import * from local_settings import *
except ImportError: except ImportError:
......
...@@ -8,8 +8,6 @@ ...@@ -8,8 +8,6 @@
<script src="{{ STATIC_URL }}js/jquery.js"></script> <script src="{{ STATIC_URL }}js/jquery.js"></script>
{% block extrascripts %} {% block extrascripts %}
{% endblock %} {% endblock %}
<link href="http://code.jquery.com/ui/1.10.1/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
<link href='http://fonts.googleapis.com/css?family=Merriweather+Sans:400,300,700' rel='stylesheet' type='text/css'/>
<link rel="stylesheet" type="text/css" media="all" href="{{ STATIC_URL }}css/style.css"/> <link rel="stylesheet" type="text/css" media="all" href="{{ STATIC_URL }}css/style.css"/>
</head> </head>
<body> <body>
......
from django.conf.urls import patterns, include, url from django.conf.urls import patterns, include, url
# Uncomment the next two lines to enable the admin:
from django.contrib import admin from django.contrib import admin
admin.autodiscover() admin.autodiscover()
urlpatterns = patterns('', urlpatterns = patterns('',
# url(r'^$', 'panikdb.views.home', name='home'), # url(r'^$', 'panikdb.views.home', name='home'),
(r'^ckeditor/', include('ckeditor.urls')),
url(r'^panikdb/', include('panikdb.emissions.urls')), url(r'^panikdb/', include('panikdb.emissions.urls')),
url(r'^admin/', include(admin.site.urls)), url(r'^admin/', include(admin.site.urls)),
......
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