Change to content to Orderable

This commit is contained in:
2024-09-16 20:16:16 +02:00
parent a70db94b2b
commit d1fe5bb187
37 changed files with 718 additions and 371 deletions

View File

@@ -0,0 +1,31 @@
# Generated by Django 5.0.8 on 2024-09-15 18:45
import django.db.models.deletion
import modelcluster.fields
import wagtail.fields
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('services', '0005_rename_carouse_image_servicespagecarousel_carousel_image_and_more'),
]
operations = [
migrations.CreateModel(
name='ServicesPageSections',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('sort_order', models.IntegerField(blank=True, editable=False, null=True)),
('section_title', wagtail.fields.RichTextField(blank=True)),
('section_text', wagtail.fields.RichTextField(blank=True)),
('section_image', wagtail.fields.RichTextField(blank=True)),
('page', modelcluster.fields.ParentalKey(on_delete=django.db.models.deletion.CASCADE, related_name='sections_services', to='services.servicespage')),
],
options={
'ordering': ['sort_order'],
'abstract': False,
},
),
]

View File

@@ -0,0 +1,20 @@
# Generated by Django 5.0.8 on 2024-09-16 12:06
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('services', '0006_servicespagesections'),
('wagtailimages', '0026_delete_uploadedimage'),
]
operations = [
migrations.AlterField(
model_name='servicespagesections',
name='section_image',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.image'),
),
]

View File

@@ -0,0 +1,34 @@
# Generated by Django 5.0.8 on 2024-09-16 12:14
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('services', '0007_alter_servicespagesections_section_image'),
('wagtailimages', '0026_delete_uploadedimage'),
]
operations = [
migrations.RenameField(
model_name='servicespage',
old_name='section_one_text',
new_name='intro_text',
),
migrations.RenameField(
model_name='servicespage',
old_name='section_one_title',
new_name='intro_title',
),
migrations.RemoveField(
model_name='servicespage',
name='section_one_img',
),
migrations.AddField(
model_name='servicespage',
name='intro_image',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.image'),
),
]

View File

@@ -0,0 +1,80 @@
# Generated by Django 5.0.8 on 2024-09-16 12:23
import django.db.models.deletion
import modelcluster.fields
import wagtail.fields
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('services', '0008_rename_section_one_text_servicespage_intro_text_and_more'),
('wagtailimages', '0026_delete_uploadedimage'),
]
operations = [
migrations.RemoveField(
model_name='servicespage',
name='section_five_img',
),
migrations.RemoveField(
model_name='servicespage',
name='section_five_text',
),
migrations.RemoveField(
model_name='servicespage',
name='section_five_title',
),
migrations.RemoveField(
model_name='servicespage',
name='section_four_img',
),
migrations.RemoveField(
model_name='servicespage',
name='section_four_text',
),
migrations.RemoveField(
model_name='servicespage',
name='section_four_title',
),
migrations.RemoveField(
model_name='servicespage',
name='section_three_img',
),
migrations.RemoveField(
model_name='servicespage',
name='section_three_text',
),
migrations.RemoveField(
model_name='servicespage',
name='section_three_title',
),
migrations.RemoveField(
model_name='servicespage',
name='section_two_img',
),
migrations.RemoveField(
model_name='servicespage',
name='section_two_text',
),
migrations.RemoveField(
model_name='servicespage',
name='section_two_title',
),
migrations.CreateModel(
name='ServicesPageSubSection',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('sort_order', models.IntegerField(blank=True, editable=False, null=True)),
('sub_section_title', wagtail.fields.RichTextField(blank=True)),
('sub_section_text', wagtail.fields.RichTextField(blank=True)),
('page', modelcluster.fields.ParentalKey(on_delete=django.db.models.deletion.CASCADE, related_name='subsections_services', to='services.servicespage')),
('sub_section_image', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.image')),
],
options={
'ordering': ['sort_order'],
'abstract': False,
},
),
]

View File

@@ -0,0 +1,17 @@
# Generated by Django 5.0.8 on 2024-09-16 12:52
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('services', '0009_remove_servicespage_section_five_img_and_more'),
]
operations = [
migrations.RemoveField(
model_name='servicespagesubsection',
name='sub_section_title',
),
]

View File

@@ -0,0 +1,61 @@
# Generated by Django 5.0.8 on 2024-09-16 12:57
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('services', '0010_remove_servicespagesubsection_sub_section_title'),
]
operations = [
migrations.RemoveField(
model_name='servicespage',
name='sub_section_five',
),
migrations.RemoveField(
model_name='servicespage',
name='sub_section_five_img',
),
migrations.RemoveField(
model_name='servicespage',
name='sub_section_four',
),
migrations.RemoveField(
model_name='servicespage',
name='sub_section_four_img',
),
migrations.RemoveField(
model_name='servicespage',
name='sub_section_one',
),
migrations.RemoveField(
model_name='servicespage',
name='sub_section_one_img',
),
migrations.RemoveField(
model_name='servicespage',
name='sub_section_six',
),
migrations.RemoveField(
model_name='servicespage',
name='sub_section_six_img',
),
migrations.RemoveField(
model_name='servicespage',
name='sub_section_three',
),
migrations.RemoveField(
model_name='servicespage',
name='sub_section_three_img',
),
migrations.RemoveField(
model_name='servicespage',
name='sub_section_two',
),
migrations.RemoveField(
model_name='servicespage',
name='sub_section_two_img',
),
]

View File

@@ -10,98 +10,24 @@ from saburly.custom_editor import FULL_EDITOR
class ServicesPage(Page):
section_one_title = RichTextField(blank=True, features=FULL_EDITOR)
section_one_text = RichTextField(blank=True, features=FULL_EDITOR)
section_one_img = RichTextField(blank=True, features=FULL_EDITOR)
section_two_title = RichTextField(blank=True, features=FULL_EDITOR)
section_two_text = RichTextField(blank=True, features=FULL_EDITOR)
section_two_img = RichTextField(blank=True, features=FULL_EDITOR)
section_three_title = RichTextField(blank=True, features=FULL_EDITOR)
section_three_text = RichTextField(blank=True, features=FULL_EDITOR)
section_three_img = RichTextField(blank=True, features=FULL_EDITOR)
section_four_title = RichTextField(blank=True, features=FULL_EDITOR)
section_four_text = RichTextField(blank=True, features=FULL_EDITOR)
section_four_img = RichTextField(blank=True, features=FULL_EDITOR)
section_five_title = RichTextField(blank=True, features=FULL_EDITOR)
section_five_text = RichTextField(blank=True, features=FULL_EDITOR)
section_five_img = RichTextField(blank=True, features=FULL_EDITOR)
sub_section_one = RichTextField(blank=True, features=FULL_EDITOR)
sub_section_one_img = RichTextField(blank=True, features=FULL_EDITOR)
sub_section_two = RichTextField(blank=True, features=FULL_EDITOR)
sub_section_two_img = RichTextField(blank=True, features=FULL_EDITOR)
sub_section_three = RichTextField(blank=True, features=FULL_EDITOR)
sub_section_three_img = RichTextField(blank=True, features=FULL_EDITOR)
sub_section_four = RichTextField(blank=True, features=FULL_EDITOR)
sub_section_four_img = RichTextField(blank=True, features=FULL_EDITOR)
sub_section_five = RichTextField(blank=True, features=FULL_EDITOR)
sub_section_five_img = RichTextField(blank=True, features=FULL_EDITOR)
sub_section_six = RichTextField(blank=True, features=FULL_EDITOR)
sub_section_six_img = RichTextField(blank=True, features=FULL_EDITOR)
intro_title = RichTextField(blank=True, features=FULL_EDITOR)
intro_text = RichTextField(blank=True, features=FULL_EDITOR)
intro_image = models.ForeignKey(
'wagtailimages.Image',
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name='+'
)
content_panels = Page.content_panels + [
MultiFieldPanel([
FieldPanel('section_one_title'),
FieldPanel('section_one_text'),
FieldPanel('section_one_img'),
], heading="Section 1"),
MultiFieldPanel([
FieldPanel('section_two_title'),
FieldPanel('section_two_text'),
FieldPanel('section_two_img'),
], heading="Section 2"),
MultiFieldPanel([
FieldPanel('section_three_title'),
FieldPanel('section_three_text'),
FieldPanel('section_three_img'),
], heading="Section 3"),
MultiFieldPanel([
FieldPanel('section_four_title'),
FieldPanel('section_four_text'),
FieldPanel('section_four_img'),
], heading="Section 4"),
MultiFieldPanel([
FieldPanel('section_five_title'),
FieldPanel('section_five_text'),
FieldPanel('section_five_img'),
], heading="Section 5"),
MultiFieldPanel([
FieldPanel('sub_section_one'),
FieldPanel('sub_section_one_img'),
FieldPanel('sub_section_two'),
FieldPanel('sub_section_two_img'),
FieldPanel('sub_section_three'),
FieldPanel('sub_section_three_img'),
FieldPanel('sub_section_four'),
FieldPanel('sub_section_four_img'),
FieldPanel('sub_section_five'),
FieldPanel('sub_section_five_img'),
FieldPanel('sub_section_six'),
FieldPanel('sub_section_six_img'),
], heading="Section 5 Subfields"),
FieldPanel('intro_title'),
FieldPanel('intro_text'),
FieldPanel('intro_image'),
], heading="Intro Section"),
InlinePanel('carousel_services', heading="Carousel Services", label="Carousel Services"),
InlinePanel('sections_services', heading="Sections Services", label="Sections Services"),
InlinePanel('subsections_services', heading="Sub-Sections Services", label="Sub-Sections Services"),
]
class ServicesPageCarousel(Orderable):
@@ -119,4 +45,40 @@ class ServicesPageCarousel(Orderable):
panels = [
FieldPanel('carousel_name'),
FieldPanel('carousel_image'),
]
class ServicesPageSections(Orderable):
page = ParentalKey(ServicesPage, on_delete=models.CASCADE, related_name='sections_services')
section_title = RichTextField(blank=True, features=FULL_EDITOR)
section_text = RichTextField(blank=True, features=FULL_EDITOR)
section_image = models.ForeignKey(
'wagtailimages.Image',
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name='+'
)
panels = [
FieldPanel('section_title'),
FieldPanel('section_text'),
FieldPanel('section_image'),
]
class ServicesPageSubSection(Orderable):
page = ParentalKey(ServicesPage, on_delete=models.CASCADE, related_name='subsections_services')
sub_section_text = RichTextField(blank=True, features=FULL_EDITOR)
sub_section_image = models.ForeignKey(
'wagtailimages.Image',
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name='+'
)
panels = [
FieldPanel('sub_section_text'),
FieldPanel('sub_section_image'),
]