Remove foreign keys between nested plugins

This commit is contained in:
M.Ravi 2017-10-18 20:24:50 +02:00
parent e563ae642f
commit db45597e4e
3 changed files with 10 additions and 22 deletions

View file

@ -67,6 +67,9 @@ class GlasfaserServicesItemPlugin(CMSPluginBase):
parent_classes = ['GlasfaserServicesPlugin'] parent_classes = ['GlasfaserServicesPlugin']
def render(self, context, instance, placeholder): def render(self, context, instance, placeholder):
context = super(GlasfaserServicesItemPlugin, self).render(
context, instance, placeholder
)
context['instance'] = instance context['instance'] = instance
return context return context
@ -95,5 +98,8 @@ class GlasfaserAboutItemPlugin(CMSPluginBase):
parent_classes = ['GlasfaserAboutPlugin'] parent_classes = ['GlasfaserAboutPlugin']
def render(self, context, instance, placeholder): def render(self, context, instance, placeholder):
context = super(GlasfaserAboutItemPlugin, self).render(
context, instance, placeholder
)
context['instance'] = instance context['instance'] = instance
return context return context

View file

@ -1,11 +1,11 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Generated by Django 1.9.4 on 2017-10-18 14:43 # Generated by Django 1.9.4 on 2017-10-18 18:23
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion import django.db.models.deletion
import djangocms_text_ckeditor.fields import djangocms_text_ckeditor.fields
import filer.fields.image import filer.fields.image
from django.db import migrations, models
class Migration(migrations.Migration): class Migration(migrations.Migration):
@ -13,8 +13,8 @@ class Migration(migrations.Migration):
initial = True initial = True
dependencies = [ dependencies = [
('cms', '0014_auto_20160404_1908'),
('filer', '0004_auto_20160328_1434'), ('filer', '0004_auto_20160328_1434'),
('cms', '0014_auto_20160404_1908'),
] ]
operations = [ operations = [
@ -36,6 +36,7 @@ class Migration(migrations.Migration):
('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')), ('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')),
('title', models.CharField(max_length=200)), ('title', models.CharField(max_length=200)),
('description', djangocms_text_ckeditor.fields.HTMLField()), ('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='service_item_image', to='filer.Image')),
], ],
options={ options={
'abstract': False, 'abstract': False,
@ -91,7 +92,6 @@ class Migration(migrations.Migration):
fields=[ fields=[
('ungelichpicture_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='ungleich_page.UngelichPicture')), ('ungelichpicture_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='ungleich_page.UngelichPicture')),
('inverted', models.BooleanField(default=False)), ('inverted', models.BooleanField(default=False)),
('glasfaser_about', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='ungleich_page.About')),
], ],
options={ options={
'abstract': False, 'abstract': False,
@ -103,14 +103,4 @@ class Migration(migrations.Migration):
name='image', name='image',
field=filer.fields.image.FilerImageField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='image', to='filer.Image'), field=filer.fields.image.FilerImageField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='image', to='filer.Image'),
), ),
migrations.AddField(
model_name='serviceitem',
name='glasfaser_service',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='ungleich_page.Service'),
),
migrations.AddField(
model_name='serviceitem',
name='image',
field=filer.fields.image.FilerImageField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='service_item_image', to='filer.Image'),
),
] ]

View file

@ -40,14 +40,10 @@ class ServiceItem(CMSPlugin):
) )
title = models.CharField(max_length=200) title = models.CharField(max_length=200)
description = HTMLField() description = HTMLField()
glasfaser_service = models.ForeignKey(Service)
def __str__(self): def __str__(self):
return self.title return self.title
def copy_relations(self, oldinstance):
self.glasfaser_service = oldinstance.glasfaser_service
class About(Service): class About(Service):
pass pass
@ -55,13 +51,9 @@ class About(Service):
class AboutItem(UngelichPicture): class AboutItem(UngelichPicture):
inverted = models.BooleanField(default=False) inverted = models.BooleanField(default=False)
glasfaser_about = models.ForeignKey(About)
def __str__(self): def __str__(self):
alignment = "Right" if self.inverted else "Left" alignment = "Right" if self.inverted else "Left"
return "{alignment} - {title}".format( return "{alignment} - {title}".format(
alignment=alignment, title=self.title alignment=alignment, title=self.title
) )
def copy_relations(self, oldinstance):
self.glasfaser_about = oldinstance.glasfaser_about