8000 Added Generic Foreign Key field to Placeholder model (#6452) · django-cms/django-cms@0aedfbb · GitHub
[go: up one dir, main page]

Skip to content

Commit 0aedfbb

Browse files
anirbanlahiri-fidelityczpython
authored andcommitted
Added Generic Foreign Key field to Placeholder model (#6452)
1 parent 1d78946 commit 0aedfbb

File tree

5 files changed

+41
-4
lines changed

5 files changed

+41
-4
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# -*- coding: utf-8 -*-
2+
# Generated by Django 1.11.14 on 2018-07-19 16:38
3+
from __future__ import unicode_literals
4+
5+
from django.db import migrations, models
6+
import django.db.models.deletion
7+
8+
9+
class Migration(migrations.Migration):
10+
11+
dependencies = [
12+
('contenttypes', '0002_remove_content_type_name'),
13+
('cms', '0022_auto_20180620_1551'),
14+
]
15+
16+
operations = [
17+
migrations.AddField(
18+
model_name='placeholder',
19+
name='content_type',
20+
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='contenttypes.ContentType'),
21+
),
22+
migrations.AddField(
23+
model_name='placeholder',
24+
name='object_id',
25+
field=models.PositiveIntegerField(blank=True, null=True),
26+
),
27+
]

cms/migrations/0023_title_placeholders.py renamed to cms/migrations/0024_title_placeholders.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
class Migration(migrations.Migration):
99

1010
dependencies = [
11-
('cms', '0022_auto_20180620_1551'),
11+
('cms', '0023_auto_20180719_1638'),
1212
]
1313

1414
operations = [
@@ -17,7 +17,7 @@ class Migration(migrations.Migration):
1717
name='placeholders',
1818
field=models.ManyToManyField(editable=False, to='cms.Placeholder'),
1919
),
20-
# Temporary field used by migration 0024
20+
# Temporary field used by migration 0025
2121
migrations.AddField(
2222
model_name='placeholder',
2323
name='title_id',

cms/migrations/0024_title_placeholders_data_migration.py renamed to cms/migrations/0025_title_placeholders_data_migration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def forwards(apps, schema_editor):
113113
class Migration(migrations.Migration):
114114

115115
dependencies = [
116-
('cms', '0023_title_placeholders'),
116+
('cms', '0024_title_placeholders'),
117117
]
118118

119119
operations = [

cms/migrations/0025_remove_page_placeholders.py renamed to cms/migrations/0026_remove_page_placeholders.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
class Migration(migrations.Migration):
99

1010
dependencies = [
11-
('cms', '0024_title_placeholders_data_migration'),
11+
('cms', '0025_title_placeholders_data_migration'),
1212
]
1313

1414
operations = [

cms/models/placeholdermodel.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
from datetime import datetime, timedelta
66

77
from django.contrib import admin
8+
from django.contrib.contenttypes.fields import GenericForeignKey
9+
from django.contrib.contenttypes.models import ContentType
810
from django.db import models
911
from django.template.defaultfilters import title
1012
from django.utils import six
@@ -35,6 +37,14 @@ class Placeholder(models.Model):
3537
"""
3638
slot = models.CharField(_("slot"), max_length=255, db_index=True, editable=False)
3739
default_width = models.PositiveSmallIntegerField(_("width"), null=True, editable=False)
40+
content_type = models.ForeignKey(
41+
ContentType,
42+
blank=True,
43+
null=True,
44+
on_delete=models.SET_NULL,
45+
)
46+
object_id = models.PositiveIntegerField(blank=True, null=True)
47+
source = GenericForeignKey('content_type', 'object_id')
3848
cache_placeholder = True
3949
is_static = False
4050
is_editable = True

0 commit comments

Comments
 (0)
0