Add ungleichproduct and ungleichproductitem plugins
This commit is contained in:
parent
16e5fb8f5c
commit
1e567ef6ad
3 changed files with 81 additions and 3 deletions
|
@ -4,7 +4,7 @@ from cms.plugin_pool import plugin_pool
|
|||
from .models import (
|
||||
UngelichContactUsSection, UngelichTextSection, Service, ServiceItem,
|
||||
About, AboutItem, SectionWithImage, UngleichServiceItem, UngleichHeader,
|
||||
UngleichHeaderItem
|
||||
UngleichHeaderItem, UngleichProductItem, UngleichProduct
|
||||
)
|
||||
|
||||
|
||||
|
@ -209,3 +209,35 @@ class UngleichHeaderItemPlugin(CMSPluginBase):
|
|||
)
|
||||
context['instance'] = instance
|
||||
return context
|
||||
|
||||
|
||||
@plugin_pool.register_plugin
|
||||
class UngleichProductsPlugin(CMSPluginBase):
|
||||
name = "ungleich Products Plugin"
|
||||
model = UngleichProduct
|
||||
render_template = "ungleich_page/ungleich/section_products.html"
|
||||
cache = False
|
||||
allow_children = True
|
||||
child_classes = ['UngleichProductsItemPlugin']
|
||||
|
||||
def render(self, context, instance, placeholder):
|
||||
context['product_instance'] = instance
|
||||
context['section_id'] = get_section_id(instance, 'products')
|
||||
return context
|
||||
|
||||
|
||||
@plugin_pool.register_plugin
|
||||
class UngleichProductsItemPlugin(CMSPluginBase):
|
||||
name = "ungleich Product Item Plugin"
|
||||
model = UngleichProductItem
|
||||
render_template = "ungleich_page/ungleich/_products_item.html"
|
||||
cache = False
|
||||
require_parent = True
|
||||
parent_classes = ['UngleichProductsPlugin']
|
||||
|
||||
def render(self, context, instance, placeholder):
|
||||
context = super(UngleichProductsItemPlugin, self).render(
|
||||
context, instance, placeholder
|
||||
)
|
||||
context['instance'] = instance
|
||||
return context
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.9.4 on 2017-11-21 19:04
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('ungleich_page', '0010_auto_20171119_1404'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='UngleichProduct',
|
||||
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)),
|
||||
],
|
||||
options={
|
||||
'abstract': False,
|
||||
},
|
||||
bases=('ungleich_page.service',),
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='UngleichProductItem',
|
||||
fields=[
|
||||
('serviceitem_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='ungleich_page.ServiceItem')),
|
||||
('url', models.URLField(blank=True, default='', max_length=300)),
|
||||
],
|
||||
options={
|
||||
'abstract': False,
|
||||
},
|
||||
bases=('ungleich_page.serviceitem',),
|
||||
),
|
||||
]
|
|
@ -116,3 +116,11 @@ class UngleichHeaderItem(CMSPlugin):
|
|||
on_delete=models.SET_NULL
|
||||
)
|
||||
description = HTMLField()
|
||||
|
||||
|
||||
class UngleichProductItem(ServiceItem):
|
||||
url = models.URLField(max_length=300, default="", blank=True)
|
||||
|
||||
|
||||
class UngleichProduct(Service):
|
||||
section_class = models.CharField(max_length=100, default="", blank=True)
|
Loading…
Reference in a new issue