From b27e30700fe5be7d9607368d398b561a09378ac8 Mon Sep 17 00:00:00 2001 From: Simon Caminada Date: Fri, 24 May 2024 12:23:39 +0200 Subject: [PATCH] feat: update iframe plugin --- src/project/cms_plugins.py | 11 +++---- src/project/migrations/0012_iframe.py | 30 +++++++++++++++++++ src/project/models.py | 11 +++++++ .../content/{flipbook.html => iframe.html} | 0 4 files changed, 47 insertions(+), 5 deletions(-) create mode 100644 src/project/migrations/0012_iframe.py rename src/project/templates/project/plugins/content/{flipbook.html => iframe.html} (100%) diff --git a/src/project/cms_plugins.py b/src/project/cms_plugins.py index 9b0bc72..1bfcfaf 100644 --- a/src/project/cms_plugins.py +++ b/src/project/cms_plugins.py @@ -15,7 +15,7 @@ from snowpenguin.django.recaptcha2.widgets import ReCaptchaWidget from project.forms import NewsletterSubscriptionForm from project.models import Section, Quote, SliderItem, SectionText, Video, DownloadSection, DownloadSectionFolder, \ TextSliderItem, HighlightListItem, ReferenceListItem, SocialMediaList, SocialMediaListItem, Timetable, \ - TimetableItem, Partner, HighlightList, Image, TitleListItem, TitleList, IntroImage, Gallery + TimetableItem, Partner, HighlightList, Image, TitleListItem, TitleList, IntroImage, Gallery, Iframe @plugin_pool.register_plugin @@ -29,7 +29,7 @@ class SectionPlugin(CMSPluginBase): 'SectionTextPlugin', 'VideoPlugin', 'DownloadSectionPlugin', 'TextSliderPlugin', 'HighlightListPlugin', 'ReferenceListPlugin', 'FormPlugin', 'PicturePlugin', 'SubPageListPlugin', 'PartnerPlugin', 'NewsletterSubscriptionPlugin', 'NewsletterArchivePlugin', - 'SocialMediaListPlugin', 'GalleryPlugin', 'FlipbookPlugin'] + 'SocialMediaListPlugin', 'GalleryPlugin', 'IframePlugin'] @plugin_pool.register_plugin @@ -351,7 +351,8 @@ class GalleryPlugin(CMSPluginBase): @plugin_pool.register_plugin -class FlipbookPlugin(CMSPluginBase): +class IframePlugin(CMSPluginBase): + model = Iframe module = 'Content' - name = 'Flipbook' - render_template = 'project/plugins/content/flipbook.html' + name = 'Iframe' + render_template = 'project/plugins/content/iframe.html' diff --git a/src/project/migrations/0012_iframe.py b/src/project/migrations/0012_iframe.py new file mode 100644 index 0000000..7361d28 --- /dev/null +++ b/src/project/migrations/0012_iframe.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.21 on 2024-05-23 15:51 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('cms', '0020_old_tree_cleanup'), + ('project', '0011_auto_20211104_1608'), + ] + + operations = [ + migrations.CreateModel( + name='Iframe', + fields=[ + ('cmsplugin_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, related_name='project_iframe', serialize=False, to='cms.CMSPlugin')), + ('html', models.TextField(verbose_name='HTML')), + ], + options={ + 'verbose_name': 'Iframe', + 'verbose_name_plural': 'Iframes', + 'abstract': False, + }, + bases=('cms.cmsplugin',), + ), + ] diff --git a/src/project/models.py b/src/project/models.py index c21b014..8b4ed51 100644 --- a/src/project/models.py +++ b/src/project/models.py @@ -349,3 +349,14 @@ class Gallery(CMSPlugin): @property def files(self): return self.folder.files.all().order_by('name') + + +class Iframe(CMSPlugin): + html = models.TextField('HTML') + + class Meta(CMSPlugin.Meta): + verbose_name = 'Iframe' + verbose_name_plural = 'Iframes' + + def __str__(self): + return self.html diff --git a/src/project/templates/project/plugins/content/flipbook.html b/src/project/templates/project/plugins/content/iframe.html similarity index 100% rename from src/project/templates/project/plugins/content/flipbook.html rename to src/project/templates/project/plugins/content/iframe.html