Add ungleich customer section, templates and migration

This commit is contained in:
PCoder 2017-11-23 09:45:38 +01:00
parent 609a49cdbb
commit 85289c2eed
5 changed files with 138 additions and 2 deletions

View file

@ -4,7 +4,8 @@ from cms.plugin_pool import plugin_pool
from .models import (
UngelichContactUsSection, UngelichTextSection, Service, ServiceItem,
About, AboutItem, SectionWithImage, UngleichServiceItem, UngleichHeader,
UngleichHeaderItem, UngleichProductItem, UngleichProduct
UngleichHeaderItem, UngleichProductItem, UngleichProduct, UngleichCustomer,
UngleichCustomerItem
)
@ -241,3 +242,35 @@ class UngleichProductsItemPlugin(CMSPluginBase):
)
context['instance'] = instance
return context
@plugin_pool.register_plugin
class UngleichCustomerSectionPlugin(CMSPluginBase):
name = "ungleich Customer Section Plugin"
model = UngleichCustomer
render_template = "ungleich_page/ungleich/section_customers.html"
cache = False
allow_children = True
child_classes = ['UngleichCustomerItemPlugin']
def render(self, context, instance, placeholder):
context['customer_instance'] = instance
context['section_id'] = get_section_id(instance, 'customer')
return context
@plugin_pool.register_plugin
class UngleichCustomerItemPlugin(CMSPluginBase):
name = "ungleich Customer Item Plugin"
model = UngleichCustomerItem
render_template = "ungleich_page/ungleich/_customer_item.html"
cache = False
require_parent = True
parent_classes = ['UngleichCustomerSectionPlugin']
def render(self, context, instance, placeholder):
context = super(UngleichCustomerItemPlugin, self).render(
context, instance, placeholder
)
context['instance'] = instance
return context

View file

@ -0,0 +1,46 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.4 on 2017-11-23 08:11
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
import djangocms_text_ckeditor.fields
import filer.fields.image
class Migration(migrations.Migration):
dependencies = [
('filer', '0005_auto_20171015_0703'),
('cms', '0014_auto_20160404_1908'),
('ungleich_page', '0011_ungleichproduct_ungleichproductitem'),
]
operations = [
migrations.CreateModel(
name='UngleichCustomer',
fields=[
('service_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='ungleich_page.Service')),
('section_class', models.CharField(blank=True, default='', max_length=100)),
('carousel_data_interval', models.IntegerField(default=3000)),
('bottom_text', djangocms_text_ckeditor.fields.HTMLField(default='<h3 class="section-subheading text-muted">*ungleich means not equal to (≠) U+2260.</h3>')),
],
options={
'abstract': False,
},
bases=('ungleich_page.service',),
),
migrations.CreateModel(
name='UngleichCustomerItem',
fields=[
('cmsplugin_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='cms.CMSPlugin')),
('url', models.URLField(blank=True, default='', max_length=300)),
('description', djangocms_text_ckeditor.fields.HTMLField()),
('image', filer.fields.image.FilerImageField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='customer_item_image', to='filer.Image')),
],
options={
'abstract': False,
},
bases=('cms.cmsplugin',),
),
]

View file

@ -123,4 +123,24 @@ class UngleichProductItem(ServiceItem):
class UngleichProduct(Service):
section_class = models.CharField(max_length=100, default="", blank=True)
section_class = models.CharField(max_length=100, default="", blank=True)
class UngleichCustomer(Service):
section_class = models.CharField(max_length=100, default="", blank=True)
carousel_data_interval = models.IntegerField(default=3000)
bottom_text = HTMLField(
default='<h3 class="section-subheading text-muted">*ungleich means '
'not equal to (≠) U+2260.</h3>'
)
class UngleichCustomerItem(CMSPlugin):
image = FilerImageField(
null=True,
blank=True,
related_name="customer_item_image",
on_delete=models.SET_NULL
)
url = models.URLField(max_length=300, default="", blank=True)
description = HTMLField()

View file

@ -0,0 +1,2 @@
<a href="{{ instance.url }}"><img class="center-block img-client img-responsive" src="{{ instance.image.url}}"></a>
<p class="carousel-text text-muted text-center">{{ instance.description }}</p>

View file

@ -0,0 +1,35 @@
{% load cms_tags custom_tags %}
<section id="{{section_id}}" class="{% if customer_instance.section_class %}{{ customer_instance.section_class }}{% else %}bg-light-gray{% endif %}">
<div class="container">
<div class="text-center wow fadeInDown" style="visibility: visible; animation-name: fadeInDown;">
<h2 class="section-heading">{{ customer_instance.title }}</h2>
<h3 class="text-muted">{{ customer_instance.sub_title }}</h3>
</div>
<div class="row">
<div class="col-sm-10 col-sm-offset-1 wow fadeInDown" style="visibility: visible; animation-name: fadeInDown;">
<!-- start:recommendationSlider -->
<div id="carousel-recommendation-ungleich" class="carousel slide ungleich ungleich-gallery ungleich-gallery-text-carousel" data-ride="carousel" data-interval="{{ customer_instance.carousel_data_interval}}">
<!-- Indicators -->
<ol class="carousel-indicators">
{% for plugin in customer_instance.child_plugin_instances %}
<li data-target="#carousel-recommendation-ungleich" data-slide-to="{{forloop.counter0}}" {% if forloop.counter0 == 0 %}class="active" {% endif %}></li>
{% endfor %}
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
{% for plugin in customer_instance.child_plugin_instances %}
<div class="item {% if forloop.counter0 == 0 %}active{% endif %}">
{% render_plugin plugin %}
</div>
{% endfor %}
</div>
</div>
<!-- end:recommendationSlider -->
</div>
</div>
</div>
<div class="text-center">
{{customer_instance.bottom_text}}
</div>
</section>