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