From f6468a7c8c6882d6a76c494308a3afcb8bfc76e4 Mon Sep 17 00:00:00 2001
From: "M.Ravi" <mondi.ravi@gmail.com>
Date: Wed, 18 Oct 2017 09:10:50 +0200
Subject: [PATCH] First attempt to services section

    - base.py: add settings to load GlasfaserServicesPlugin by default
    - glasfaser_cms_page.html: create a placeholder for services
    - cms_plugins.py: add the plugin code
    - models.py: add UngelichTextSectionWithImage model
---
 dynamicweb/settings/base.py                   |  9 ++++
 ungleich_page/cms_plugins.py                  | 18 +++++++-
 ungleich_page/models.py                       |  9 ++++
 .../ungleich_page/glasfaser_cms_page.html     | 43 +------------------
 4 files changed, 36 insertions(+), 43 deletions(-)

diff --git a/dynamicweb/settings/base.py b/dynamicweb/settings/base.py
index 58e9065a..611439cd 100644
--- a/dynamicweb/settings/base.py
+++ b/dynamicweb/settings/base.py
@@ -321,6 +321,15 @@ CMS_PLACEHOLDER_CONF = {
             },
         ]
     },
+    'glasfaser_services': {
+        'name': "Services",
+        'plugins': ['GlasfaserServicesPlugin'],
+        'default_plugins': [
+            {
+                'plugin_type': 'GlasfaserServicesPlugin',
+            },
+        ]
+    },
 }
 
 CACHES = {
diff --git a/ungleich_page/cms_plugins.py b/ungleich_page/cms_plugins.py
index a6c8747f..1731a7f4 100644
--- a/ungleich_page/cms_plugins.py
+++ b/ungleich_page/cms_plugins.py
@@ -2,7 +2,8 @@ from cms.plugin_base import CMSPluginBase
 from cms.plugin_pool import plugin_pool
 
 from .models import (
-    UngelichPicture, UngelichContactUsSection, UngelichTextSection
+    UngelichPicture, UngelichContactUsSection, UngelichTextSection,
+    UngelichTextSectionWithImage
 )
 
 
@@ -40,3 +41,18 @@ class SectionTextParagraphGlasfaser(CMSPluginBase):
     model = UngelichTextSection
     render_template = "ungleich_page/glasfaser/section_text_glasfaser.html"
     cache = False
+
+
+@plugin_pool.register_plugin
+class GlasfaserServicesPlugin(CMSPluginBase):
+    model = UngelichTextSectionWithImage
+    render_template = "ungleich_page/glasfaser/section_services.html"
+    cache = False
+
+    def render(self, context, instance, placeholder):
+        context.update({
+            'image': instance.image,
+            'object': instance,
+            'placeholder': placeholder
+        })
+        return context
diff --git a/ungleich_page/models.py b/ungleich_page/models.py
index c371020d..e5916f18 100644
--- a/ungleich_page/models.py
+++ b/ungleich_page/models.py
@@ -21,3 +21,12 @@ class UngelichContactUsSection(CMSPlugin):
 class UngelichTextSection(CMSPlugin):
     title = models.CharField(max_length=200)
     description = HTMLField()
+
+
+class UngelichTextSectionWithImage(UngelichTextSection):
+    image = FilerImageField(
+        null=True,
+        blank=True,
+        related_name="utswi_image",
+        on_delete=models.SET_NULL
+    )
\ No newline at end of file
diff --git a/ungleich_page/templates/ungleich_page/glasfaser_cms_page.html b/ungleich_page/templates/ungleich_page/glasfaser_cms_page.html
index 2e167109..dc5811ea 100644
--- a/ungleich_page/templates/ungleich_page/glasfaser_cms_page.html
+++ b/ungleich_page/templates/ungleich_page/glasfaser_cms_page.html
@@ -80,48 +80,7 @@
 
    {% placeholder 'Middle Section' %}
 
-
-
-    <section id="services">
-      <div class="container">
-        <div class="text-center wow fadeInDown">
-          <h2 class="section-heading">Technische Details</h2>
-          <h3 class="section-subheading text-muted">Im Angebot enthalten sind</h3>
-        </div>
-        <div class="row text-center">
-          <div class="col-sm-4">
-            <div class="team-member wow fadeInUp" data-wow-delay="0.25s">
-              <img src="{% static 'ungleich_page/img/glasfaser/business.svg' %}" class="img-responsive img-circle" alt="">
-              <div class="team-member-caption inline-block">
-                <h4 class="portfolio-caption">Business-Internet</h4>
-                <p class="text-muted">Symmetrische Internetleitung 100 Mbit/s upload und 100 Mbit/s download</p>
-                <p class="text-muted">Glasfaser-Installation bis ins Haus (keine Hausverkabelung)</p>
-              </div>
-            </div>
-          </div>
-          <div class="col-sm-4">
-            <div class="team-member wow fadeInUp" data-wow-delay="0.5s">
-              <img src="{% static 'ungleich_page/img/glasfaser/ip.svg' %}" class="img-responsive img-circle" alt="">
-              <div class="team-member-caption inline-block">
-                <h4 class="portfolio-caption">Erreichbarkeit im Internet</h4>
-                <p class="text-muted">1 öffentliches IPv6-Netzwerk (/64)</p>
-                <p class="text-muted">1 öffentliche IPv4-Adresse</p>
-              </div>
-            </div>
-          </div>
-          <div class="col-sm-4">
-            <div class="team-member wow fadeInUp" data-wow-delay="0.75s">
-              <img src="{% static 'ungleich_page/img/glasfaser/switch.svg' %}" class="img-responsive img-circle" alt="">
-              <div class="team-member-caption inline-block">
-                <h4 class="portfolio-caption">Einfach zu nutzen</h4>
-                <p class="text-muted">2 vorkonfigurierte Endgeräte (benötigt zwei Steckdosen auf Ihrer Seite)</p>
-                <p class="text-muted">Einfach einstecken und los!</p>
-              </div>
-            </div>
-          </div>
-        </div>
-      </div>
-    </section>
+   {% placeholder 'Glasfaser Services' %}
 
     <!-- About Section -->
     <section id="about">