'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
+ 'ckeditor',
'gadjo',
'sorl.thumbnail',
'earwig.sounds',
# Login/registration
LOGIN_REDIRECT_URL = '/'
+# ckeditor
+CKEDITOR_UPLOAD_PATH = 'uploads/'
+CKEDITOR_CONFIGS = {
+ 'default': {
+ 'allowedContent': True,
+ 'removePlugins': 'stylesheetparser',
+ 'toolbar_Own': [['Source', 'Format', '-', 'Bold', 'Italic'],
+ ['NumberedList', 'BulletedList'],
+ ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'],
+ ['Link', 'Unlink'],
+ ['HorizontalRule'],
+ ['RemoveFormat',],
+ ['Maximize']],
+ 'toolbar': 'Own',
+ 'resize_enabled': False,
+ },
+}
+
local_settings_file = os.environ.get('EARWIG_SETTINGS_FILE',
os.path.join(os.path.dirname(__file__), 'local_settings.py'))
--- /dev/null
+# -*- coding: utf-8 -*-
+#
+# earwig
+# Copyright (C) 2018 Frederic Peters
+#
+# This program is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as published
+# by the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Originally from Combo, (AGPL as well),
+# <http://git.entrouvert.org/combo.git/tree/combo/data/fields.py>
+
+from django.conf import settings
+
+import ckeditor.fields
+
+
+class RichTextField(ckeditor.fields.RichTextField):
+ def formfield(self, **kwargs):
+ defaults = {
+ 'form_class': RichTextFormField,
+ 'config_name': self.config_name,
+ 'extra_plugins' : self.extra_plugins,
+ 'external_plugin_resources': self.external_plugin_resources
+ }
+ defaults.update(kwargs)
+ return super(RichTextField, self).formfield(**defaults)
+
+
+class RichTextFormField(ckeditor.fields.RichTextFormField):
+ def clean(self, value):
+ value = super(RichTextFormField, self).clean(value)
+ if settings.LANGUAGE_CODE.startswith('fr-'):
+ # apply some typographic rules
+ value = value.replace(u'« ', u'«\u202f')
+ value = value.replace(u'« ', u'«\u202f')
+ value = value.replace(u' »', u'\u202f»')
+ value = value.replace(u' »', u'\u202f»')
+ value = value.replace(u' :', u'\u00a0:')
+ value = value.replace(u' ;', u'\u202f;')
+ value = value.replace(u' !', u'\u202f!')
+ value = value.replace(u' ?', u'\u202f?')
+ return value
--- /dev/null
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.11 on 2018-09-02 07:22
+from __future__ import unicode_literals
+
+from django.db import migrations
+import earwig.sounds.fields
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('sounds', '0004_channel_last_check_timestamp'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='sound',
+ name='description',
+ field=earwig.sounds.fields.RichTextField(blank=True, null=True, verbose_name='Description'),
+ ),
+ ]
from django.db import models
from django.utils.translation import ugettext_lazy as _
+from .fields import RichTextField
+
+
POLICIES = [
('', _('Default (moderate)')),
('publish', _('Autopublish')),
class Sound(models.Model):
sound_url = models.URLField(_('Sound URL'))
title = models.CharField(_('Title'), max_length=200)
- description = models.TextField(_('Description'), blank=True)
+ description = RichTextField(_('Description'), blank=True, null=True)
page_url = models.URLField(_('Page URL'), blank=True)
uuid = models.CharField(_('Unique Identifier'), max_length=200, blank=True, null=True)
channel = models.ForeignKey('Channel', on_delete=models.SET_NULL, blank=True, null=True)