kopia lustrzana https://github.com/rtts/django-simplecms
Another try at making both the Page and Section models be swappable (damn
migrations!)readwriteweb
rodzic
75196b08b2
commit
bd8d82d4e7
|
@ -1,4 +1,4 @@
|
||||||
# Generated by Django 3.0.2 on 2020-01-05 11:43
|
# Generated by Django 3.0.2 on 2020-02-16 14:27
|
||||||
|
|
||||||
import cms.models
|
import cms.models
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
@ -12,6 +12,7 @@ class Migration(migrations.Migration):
|
||||||
initial = True
|
initial = True
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
migrations.swappable_dependency(settings.CMS_PAGE_MODEL),
|
||||||
('contenttypes', '0002_remove_content_type_name'),
|
('contenttypes', '0002_remove_content_type_name'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -21,8 +22,8 @@ class Migration(migrations.Migration):
|
||||||
fields=[
|
fields=[
|
||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
('number', models.PositiveIntegerField(blank=True, verbose_name='number')),
|
('number', models.PositiveIntegerField(blank=True, verbose_name='number')),
|
||||||
('slug', models.SlugField(blank=True, unique=True, verbose_name='slug')),
|
|
||||||
('title', cms.models.VarCharField(verbose_name='title')),
|
('title', cms.models.VarCharField(verbose_name='title')),
|
||||||
|
('slug', models.SlugField(blank=True, unique=True, verbose_name='slug')),
|
||||||
('menu', models.BooleanField(default=True, verbose_name='visible in menu')),
|
('menu', models.BooleanField(default=True, verbose_name='visible in menu')),
|
||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
|
|
|
@ -0,0 +1,59 @@
|
||||||
|
# Generated by Django 3.0.2 on 2020-02-16 14:27
|
||||||
|
|
||||||
|
import cms.models
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
import embed_video.fields
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('contenttypes', '0002_remove_content_type_name'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Page',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('number', models.PositiveIntegerField(blank=True, verbose_name='number')),
|
||||||
|
('title', cms.models.VarCharField(verbose_name='title')),
|
||||||
|
('slug', models.SlugField(blank=True, unique=True, verbose_name='slug')),
|
||||||
|
('menu', models.BooleanField(default=True, verbose_name='visible in menu')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Page',
|
||||||
|
'verbose_name_plural': 'Pages',
|
||||||
|
'ordering': ['number'],
|
||||||
|
'abstract': False,
|
||||||
|
},
|
||||||
|
bases=(cms.models.Numbered, models.Model),
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Section',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('type', cms.models.VarCharField(blank=True, verbose_name='type')),
|
||||||
|
('number', models.PositiveIntegerField(blank=True, verbose_name='number')),
|
||||||
|
('title', cms.models.VarCharField(blank=True, verbose_name='title')),
|
||||||
|
('content', models.TextField(blank=True, verbose_name='content')),
|
||||||
|
('image', models.ImageField(blank=True, upload_to='', verbose_name='image')),
|
||||||
|
('video', embed_video.fields.EmbedVideoField(blank=True, help_text='Paste a YouTube, Vimeo, or SoundCloud link', verbose_name='video')),
|
||||||
|
('button_text', cms.models.VarCharField(blank=True, verbose_name='button text')),
|
||||||
|
('button_link', cms.models.VarCharField(blank=True, verbose_name='button link')),
|
||||||
|
('page', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='sections', to=settings.CMS_PAGE_MODEL, verbose_name='page')),
|
||||||
|
('polymorphic_ctype', models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='polymorphic_app.section_set+', to='contenttypes.ContentType')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'section',
|
||||||
|
'verbose_name_plural': 'sections',
|
||||||
|
'ordering': ['number'],
|
||||||
|
'abstract': False,
|
||||||
|
},
|
||||||
|
bases=(cms.models.Numbered, models.Model),
|
||||||
|
),
|
||||||
|
]
|
|
@ -14,7 +14,6 @@ class Section(BaseSection):
|
||||||
title, content, image, video, button_text, button_link
|
title, content, image, video, button_text, button_link
|
||||||
|
|
||||||
'''
|
'''
|
||||||
color = models.PositiveIntegerField('kleur', default=1, choices=settings.SECTION_COLORS)
|
|
||||||
|
|
||||||
@register_model('Tekst')
|
@register_model('Tekst')
|
||||||
class TextSection(Section):
|
class TextSection(Section):
|
||||||
|
|
|
@ -22,10 +22,8 @@ STATIC_ROOT = '/srv/' + PROJECT_NAME + '/static'
|
||||||
MEDIA_URL = '/media/'
|
MEDIA_URL = '/media/'
|
||||||
MEDIA_ROOT = '/srv/' + PROJECT_NAME + '/media'
|
MEDIA_ROOT = '/srv/' + PROJECT_NAME + '/media'
|
||||||
LOGIN_REDIRECT_URL = '/'
|
LOGIN_REDIRECT_URL = '/'
|
||||||
|
|
||||||
CMS_SECTION_MODEL = 'app.Section'
|
CMS_SECTION_MODEL = 'app.Section'
|
||||||
# CMS_PAGE_MODEL = 'app.Page' # https://github.com/wq/django-swappable-models/issues/18#issuecomment-514039164
|
CMS_PAGE_MODEL = 'app.Page' # https://github.com/wq/django-swappable-models/issues/18#issuecomment-514039164
|
||||||
|
|
||||||
MARKDOWN_EXTENSIONS = ['extra', 'smarty']
|
MARKDOWN_EXTENSIONS = ['extra', 'smarty']
|
||||||
|
|
||||||
def read(file):
|
def read(file):
|
||||||
|
@ -40,11 +38,6 @@ except IOError:
|
||||||
SECRET_KEY = ''.join(random.choice(string.printable) for x in range(50))
|
SECRET_KEY = ''.join(random.choice(string.printable) for x in range(50))
|
||||||
write(KEYFILE, SECRET_KEY)
|
write(KEYFILE, SECRET_KEY)
|
||||||
|
|
||||||
SECTION_COLORS = [
|
|
||||||
(1, 'Licht'),
|
|
||||||
(2, 'Donker'),
|
|
||||||
]
|
|
||||||
|
|
||||||
INSTALLED_APPS = [
|
INSTALLED_APPS = [
|
||||||
'app',
|
'app',
|
||||||
'django.contrib.admin',
|
'django.contrib.admin',
|
||||||
|
|
Ładowanie…
Reference in New Issue