add created and modified fields
This commit is contained in:
parent
aa9015da9e
commit
52870818ea
7 changed files with 28 additions and 88 deletions
|
@ -1,5 +1,5 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Generated by Django 1.10.3 on 2016-11-24 20:51
|
# Generated by Django 1.10.3 on 2016-11-28 21:53
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
@ -12,8 +12,8 @@ class Migration(migrations.Migration):
|
||||||
initial = True
|
initial = True
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('wagtailcore', '0030_index_on_pagerevision_created_at'),
|
|
||||||
('wagtailimages', '0015_fill_filter_spec_field'),
|
('wagtailimages', '0015_fill_filter_spec_field'),
|
||||||
|
('wagtailcore', '0030_index_on_pagerevision_created_at'),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
|
@ -21,6 +21,8 @@ class Migration(migrations.Migration):
|
||||||
name='BlogPage',
|
name='BlogPage',
|
||||||
fields=[
|
fields=[
|
||||||
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')),
|
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')),
|
||||||
|
('created', models.DateTimeField(auto_now_add=True)),
|
||||||
|
('modified', models.DateTimeField(auto_now=True)),
|
||||||
('date', models.DateField(verbose_name='Post date')),
|
('date', models.DateField(verbose_name='Post date')),
|
||||||
('intro', models.CharField(max_length=250)),
|
('intro', models.CharField(max_length=250)),
|
||||||
('body', wagtail.wagtailcore.fields.RichTextField(blank=True)),
|
('body', wagtail.wagtailcore.fields.RichTextField(blank=True)),
|
||||||
|
|
|
@ -1,9 +1,13 @@
|
||||||
from wagtail.wagtailcore.models import Page
|
from wagtail.wagtailcore.models import Page
|
||||||
|
from django.db import models
|
||||||
|
|
||||||
|
|
||||||
class Entity(Page):
|
class Entity(Page):
|
||||||
is_home = False
|
is_home = False
|
||||||
|
|
||||||
|
created = models.DateTimeField(auto_now_add=True)
|
||||||
|
modified = models.DateTimeField(auto_now=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
abstract = True
|
abstract = True
|
||||||
|
|
||||||
|
|
12
project/home/migrations/0001_initial.py
Executable file → Normal file
12
project/home/migrations/0001_initial.py
Executable file → Normal file
|
@ -1,20 +1,28 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.10.3 on 2016-11-28 21:53
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
import wagtail.wagtailcore.fields
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('wagtailcore', '0029_unicode_slugfield_dj19'),
|
('wagtailcore', '0030_index_on_pagerevision_created_at'),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='HomePage',
|
name='HomePage',
|
||||||
fields=[
|
fields=[
|
||||||
('page_ptr', models.OneToOneField(on_delete=models.CASCADE, parent_link=True, auto_created=True, primary_key=True, serialize=False, to='wagtailcore.Page')),
|
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')),
|
||||||
|
('created', models.DateTimeField(auto_now_add=True)),
|
||||||
|
('modified', models.DateTimeField(auto_now=True)),
|
||||||
|
('body', wagtail.wagtailcore.fields.RichTextField(blank=True)),
|
||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
'abstract': False,
|
'abstract': False,
|
||||||
|
|
|
@ -1,59 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import migrations
|
|
||||||
|
|
||||||
|
|
||||||
def create_homepage(apps, schema_editor):
|
|
||||||
# Get models
|
|
||||||
ContentType = apps.get_model('contenttypes.ContentType')
|
|
||||||
Page = apps.get_model('wagtailcore.Page')
|
|
||||||
Site = apps.get_model('wagtailcore.Site')
|
|
||||||
HomePage = apps.get_model('home.HomePage')
|
|
||||||
|
|
||||||
# Delete the default homepage
|
|
||||||
# If migration is run multiple times, it may have already been deleted
|
|
||||||
Page.objects.filter(id=2).delete()
|
|
||||||
|
|
||||||
# Create content type for homepage model
|
|
||||||
homepage_content_type, __ = ContentType.objects.get_or_create(
|
|
||||||
model='homepage', app_label='home')
|
|
||||||
|
|
||||||
# Create a new homepage
|
|
||||||
homepage = HomePage.objects.create(
|
|
||||||
title="Homepage",
|
|
||||||
slug='home',
|
|
||||||
content_type=homepage_content_type,
|
|
||||||
path='00010001',
|
|
||||||
depth=2,
|
|
||||||
numchild=0,
|
|
||||||
url_path='/home/',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Create a site with the new homepage set as the root
|
|
||||||
Site.objects.create(
|
|
||||||
hostname='localhost', root_page=homepage, is_default_site=True)
|
|
||||||
|
|
||||||
|
|
||||||
def remove_homepage(apps, schema_editor):
|
|
||||||
# Get models
|
|
||||||
ContentType = apps.get_model('contenttypes.ContentType')
|
|
||||||
HomePage = apps.get_model('home.HomePage')
|
|
||||||
|
|
||||||
# Delete the default homepage
|
|
||||||
# Page and Site objects CASCADE
|
|
||||||
HomePage.objects.filter(slug='home', depth=2).delete()
|
|
||||||
|
|
||||||
# Delete content type for homepage model
|
|
||||||
ContentType.objects.filter(model='homepage', app_label='home').delete()
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('home', '0001_initial'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.RunPython(create_homepage, remove_homepage),
|
|
||||||
]
|
|
|
@ -1,21 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
# Generated by Django 1.10.3 on 2016-11-18 22:28
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import migrations
|
|
||||||
import wagtail.wagtailcore.fields
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('home', '0002_create_homepage'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='homepage',
|
|
||||||
name='body',
|
|
||||||
field=wagtail.wagtailcore.fields.RichTextField(blank=True),
|
|
||||||
),
|
|
||||||
]
|
|
|
@ -1,5 +1,5 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Generated by Django 1.10.3 on 2016-11-28 21:29
|
# Generated by Django 1.10.3 on 2016-11-28 21:53
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
@ -20,6 +20,8 @@ class Migration(migrations.Migration):
|
||||||
name='SectionIndexPage',
|
name='SectionIndexPage',
|
||||||
fields=[
|
fields=[
|
||||||
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')),
|
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')),
|
||||||
|
('created', models.DateTimeField(auto_now_add=True)),
|
||||||
|
('modified', models.DateTimeField(auto_now=True)),
|
||||||
('intro', wagtail.wagtailcore.fields.RichTextField(blank=True)),
|
('intro', wagtail.wagtailcore.fields.RichTextField(blank=True)),
|
||||||
('hide_list', models.BooleanField(default=False)),
|
('hide_list', models.BooleanField(default=False)),
|
||||||
],
|
],
|
||||||
|
@ -32,6 +34,8 @@ class Migration(migrations.Migration):
|
||||||
name='SimpleContentPage',
|
name='SimpleContentPage',
|
||||||
fields=[
|
fields=[
|
||||||
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')),
|
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')),
|
||||||
|
('created', models.DateTimeField(auto_now_add=True)),
|
||||||
|
('modified', models.DateTimeField(auto_now=True)),
|
||||||
('body', wagtail.wagtailcore.fields.RichTextField()),
|
('body', wagtail.wagtailcore.fields.RichTextField()),
|
||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Generated by Django 1.10.3 on 2016-11-28 21:46
|
# Generated by Django 1.10.3 on 2016-11-28 21:53
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
@ -13,9 +13,9 @@ class Migration(migrations.Migration):
|
||||||
initial = True
|
initial = True
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('wagtailcore', '0030_index_on_pagerevision_created_at'),
|
|
||||||
('wagtailimages', '0015_fill_filter_spec_field'),
|
|
||||||
('wagtaildocs', '0007_merge'),
|
('wagtaildocs', '0007_merge'),
|
||||||
|
('wagtailimages', '0015_fill_filter_spec_field'),
|
||||||
|
('wagtailcore', '0030_index_on_pagerevision_created_at'),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
|
@ -23,6 +23,8 @@ class Migration(migrations.Migration):
|
||||||
name='ProjectPage',
|
name='ProjectPage',
|
||||||
fields=[
|
fields=[
|
||||||
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')),
|
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')),
|
||||||
|
('created', models.DateTimeField(auto_now_add=True)),
|
||||||
|
('modified', models.DateTimeField(auto_now=True)),
|
||||||
('summary', models.CharField(max_length=500)),
|
('summary', models.CharField(max_length=500)),
|
||||||
('body', wagtail.wagtailcore.fields.RichTextField()),
|
('body', wagtail.wagtailcore.fields.RichTextField()),
|
||||||
('project_url', models.URLField(blank=True, validators=[project.projects.models.validate_url])),
|
('project_url', models.URLField(blank=True, validators=[project.projects.models.validate_url])),
|
||||||
|
|
Reference in a new issue