diff --git a/ungleich_page/cms_plugins.py b/ungleich_page/cms_plugins.py index 21c6f8d9..8f2b1883 100644 --- a/ungleich_page/cms_plugins.py +++ b/ungleich_page/cms_plugins.py @@ -1,14 +1,24 @@ +from cms.models.pluginmodel import CMSPlugin from cms.plugin_base import CMSPluginBase from cms.plugin_pool import plugin_pool -from cms.models.pluginmodel import CMSPlugin + +from .models import UngelichPicture @plugin_pool.register_plugin class SectionWithImagePlugin(CMSPluginBase): - model = CMSPlugin + model = UngelichPicture render_template = "ungleich_page/glasfaser/section_with_image.html" cache = False + def render(self, context, instance, placeholder): + context.update({ + 'image': instance.image, + 'object': instance, + 'placeholder': placeholder + }) + return context + @plugin_pool.register_plugin class SectionContact(CMSPluginBase): diff --git a/ungleich_page/models.py b/ungleich_page/models.py index 0b4331b3..4199e6f7 100644 --- a/ungleich_page/models.py +++ b/ungleich_page/models.py @@ -1,3 +1,13 @@ -# from django.db import models +from cms.models.pluginmodel import CMSPlugin +from django.db import models +from filer.fields.image import FilerImageField -# Create your models here. + +class UngelichPicture(CMSPlugin): + image = FilerImageField( + null=True, + blank=True, + related_name="image", + on_delete=models.SET_NULL + ) + title = models.CharField(max_length=200) diff --git a/ungleich_page/templates/ungleich_page/glasfaser/section_with_image.html b/ungleich_page/templates/ungleich_page/glasfaser/section_with_image.html index 0990a3f2..b3477ffe 100644 --- a/ungleich_page/templates/ungleich_page/glasfaser/section_with_image.html +++ b/ungleich_page/templates/ungleich_page/glasfaser/section_with_image.html @@ -1,10 +1,7 @@ -