# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('cms', '0001_initial'),
        ('form_designer', '0001_initial'),
    ]

    operations = [
        migrations.CreateModel(
            name='CMSFormDefinition',
            fields=[
                ('cmsplugin_ptr', models.OneToOneField(serialize=False, auto_created=True, primary_key=True, to='cms.CMSPlugin', parent_link=True)),
                ('form_definition', models.ForeignKey(verbose_name='form', to='form_designer.FormDefinition')),
            ],
            options={
                'abstract': False,
            },
            bases=('cms.cmsplugin',),
        ),
    ]

# -*- coding: utf-8 -*-
from __future__ import unicode_literals

import cms
from django.db import migrations, models
from pkg_resources import parse_version as V

# Django CMS 3.3.1 is oldest release where the change affects.
# Refs https://github.com/divio/django-cms/commit/871a164
if V(cms.__version__) >= V('3.3.1'):
    field_kwargs = {'related_name': 'form_designer_form_cmsformdefinition'}
else:
    field_kwargs = {}


class Migration(migrations.Migration):
    dependencies = [
        ('cms', '0001_initial'),
        ('form_designer', '0001_initial'),
    ]

    operations = [
        migrations.CreateModel(
            name='CMSFormDefinition',
            fields=[
                ('cmsplugin_ptr',
                 models.OneToOneField(
                     serialize=False,
                     auto_created=True,
                     primary_key=True,
                     to='cms.CMSPlugin',
                     parent_link=True,
                     **field_kwargs)),
                ('form_definition',
                 models.ForeignKey(
                     verbose_name='form',
                     to='form_designer.FormDefinition')),
            ],
            options={
                'abstract': False,
            },
            bases=(
                'cms.cmsplugin',
            ),
        ),
    ]

Add related name for cmsplugin ptr
Add related name for cmsplugin ptr

Add the related name for the cmsplugin_ptr field if the Django CMS version is 3.3.1 or newer. The related name is added to the base model in Django CMS see: https://github.com/divio/django-cms/commit/871a16433f713249ee20b52574803f51941ac20c
