diff --git a/app/settings.py b/app/settings.py index 00c4178..e56ded4 100644 --- a/app/settings.py +++ b/app/settings.py @@ -216,6 +216,72 @@ 'dialogui', 'elementspath' ]), + }, + 'small': { + 'toolbar_Article': [ + { + 'name': 'styles', + 'items': ['Styles', 'Format', 'FontSize', 'Source', '-', 'ShowBlocks', 'Maximize'], + }, + '/', + { + 'name': 'justify', + 'items': ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'], + }, + { + 'name': + 'basicstyles', + 'items': [ + 'Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', + 'Blockquote', '-', 'RemoveFormat' + ], + }, + { + 'name': 'colors', + 'items': ['TextColor', 'BGColor'], + }, + { + 'name': 'clipboard', + 'items': ['Cut', 'Copy', 'SelectAll', '-', 'Undo', 'Redo'], + }, + '/', + { + 'name': 'paragraph', + 'items': ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent'], + }, + { + 'name': 'links', + 'items': ['Link', 'Unlink', 'Anchor'] + }, + ], + 'toolbar': + 'Article', + 'height': + 300, + 'width': + 600, + 'forcePasteAsPlainText': + True, + 'font_names': + 'Arial/Arial, Helvetica, sans-serif', + 'font_defaultLabel': + 'Arial', + 'tabSpaces': + 4, + 'contentsCss': + '/static/ckeditor/editor.css', + 'extraPlugins': + ','.join([ + # your extra plugins here + 'autolink', + # 'devtools', + 'widget', + 'lineutils', + 'clipboard', + 'dialog', + 'dialogui', + 'elementspath' + ]), } } diff --git a/data_models/admin.py b/data_models/admin.py index fd7295d..6f1b26e 100644 --- a/data_models/admin.py +++ b/data_models/admin.py @@ -53,6 +53,23 @@ class Meta: fields = '__all__' +class ShowAdminForm(forms.ModelForm): + content = forms.CharField( + widget=CKEditorUploadingWidget(config_name='small'), label='Lang beskrivelse') + + class Meta: + model = Show + fields = '__all__' + + +class EpisodeAdminForm(forms.ModelForm): + lead = forms.CharField(widget=CKEditorUploadingWidget(config_name='small'), label='Beskrivelse') + + class Meta: + model = Episode + fields = '__all__' + + @admin.register(Post) class PostAdmin(ImageCroppingMixin, admin.ModelAdmin): list_display = ('title', 'show', 'publish_at', 'ready_to_be_published', 'deleted') @@ -91,13 +108,7 @@ class ShowAdmin(admin.ModelAdmin): list_filter = ('archived', ) ordering = ('archived', 'name') search_fields = ('name', ) - - # Set form field for "lead" to Textarea instead of Textinput - def formfield_for_dbfield(self, db_field, **kwargs): - formfield = super(ShowAdmin, self).formfield_for_dbfield(db_field, **kwargs) - if db_field.name == 'lead': - formfield.widget = forms.Textarea(attrs={'cols': 40, 'rows': 3}) - return formfield + form = ShowAdminForm @admin.register(Episode) @@ -105,10 +116,4 @@ class EpisodeAdmin(admin.ModelAdmin): list_display = ('title', 'show', 'publish_at') list_filter = (ActiveShowFilter, ArchivedShowFilter) search_fields = ('title', 'show__name') - - # Set form field for "lead" to Textarea instead of Textinput - def formfield_for_dbfield(self, db_field, **kwargs): - formfield = super(EpisodeAdmin, self).formfield_for_dbfield(db_field, **kwargs) - if db_field.name == 'lead': - formfield.widget = forms.Textarea(attrs={'cols': 60, 'rows': 5}) - return formfield + form = EpisodeAdminForm diff --git a/data_models/migrations/0021_more_textfields.py b/data_models/migrations/0021_more_textfields.py new file mode 100644 index 0000000..ead3d22 --- /dev/null +++ b/data_models/migrations/0021_more_textfields.py @@ -0,0 +1,23 @@ +# Generated by Django 2.0.12 on 2019-03-18 20:01 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('data_models', '0020_settings_music_producer'), + ] + + operations = [ + migrations.AlterField( + model_name='episode', + name='lead', + field=models.TextField(verbose_name='Beskrivelse'), + ), + migrations.AlterField( + model_name='show', + name='lead', + field=models.TextField(max_length=255, verbose_name='Kort beskrivelse'), + ), + ] diff --git a/data_models/models.py b/data_models/models.py index b59a8a3..e18558b 100644 --- a/data_models/models.py +++ b/data_models/models.py @@ -51,7 +51,7 @@ class Meta: name = models.CharField('Navn', max_length=64, unique=True) slug = AutoSlugField(populate_from=['name']) image = models.ImageField('Programlogo', upload_to='uploads/images') - lead = models.CharField('Kort beskrivelse', max_length=140) + lead = models.TextField('Kort beskrivelse', max_length=255) content = models.TextField('Lang beskrivelse') categories = models.ManyToManyField(Category, blank=True, verbose_name='Kategorier') @@ -85,7 +85,7 @@ class Meta: default=False, help_text='Vis tittelen på episoden. ' + 'Om ikke tittel benyttes vises "Navn på show" + "Publiseringsdato"') - lead = models.CharField('Beskrivelse', max_length=140) + lead = models.TextField('Beskrivelse') show = models.ForeignKey( Show,