Skip to content

Commit

Permalink
refactor: Greatly simplified exhibit page handling and template layouts
Browse files Browse the repository at this point in the history
hepplerj committed Sep 26, 2024
1 parent 7cd8829 commit 73dad7f
Showing 10 changed files with 814 additions and 447 deletions.
108 changes: 108 additions & 0 deletions exhibits/migrations/0016_exhibitpage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# Generated by Django 5.0.6 on 2024-09-26 17:12

import django.db.models.deletion
import wagtail.fields
from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("exhibits", "0015_exhibithome_is_chapter_intro_page_and_more"),
("wagtailcore", "0093_uploadedfile"),
("wagtailimages", "0026_delete_uploadedimage"),
]

operations = [
migrations.CreateModel(
name="ExhibitPage",
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",
),
),
(
"layout",
models.CharField(
choices=[
("left_image_one_third", "Left Image, One Third"),
("right_image_one_third", "Right Image, One Third"),
("left_image_two_thirds", "Left Image, Two Thirds"),
("right_image_two_thirds", "Right Image, Two Thirds"),
("half_and_half", "Half and Half"),
("full_screen", "Full Screen"),
("wide_image", "Wide Image"),
("comparison_image", "Comparison Image"),
],
default="left_image_one_third",
help_text="Select the layout for this exhibit page.",
max_length=22,
),
),
(
"image_caption",
models.CharField(
blank=True,
help_text="Caption for the exhibit page image.",
max_length=500,
verbose_name="Image caption",
),
),
("body", wagtail.fields.RichTextField(blank=True)),
(
"is_end_of_exhibit",
models.BooleanField(
default=False,
help_text="Is this the last page of the exhibit? If checked, yes.",
),
),
(
"is_chapter_intro_page",
models.BooleanField(
default=False,
help_text="Is this the first page of a chapter? If checked, yes.",
),
),
(
"image",
models.ForeignKey(
help_text="Image for the exhibit page.",
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="+",
to="wagtailimages.image",
),
),
(
"link_to_next_page",
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="+",
to="wagtailcore.page",
),
),
(
"link_to_previous_page",
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="+",
to="wagtailcore.page",
),
),
],
options={
"abstract": False,
},
bases=("wagtailcore.page",),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Generated by Django 5.0.6 on 2024-09-26 17:47

import django.db.models.deletion
import modelcluster.fields
from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("exhibits", "0016_exhibitpage"),
("wagtailimages", "0026_delete_uploadedimage"),
]

operations = [
migrations.AlterField(
model_name="imagecomparison",
name="first_image",
field=models.ForeignKey(
help_text="First image to compare",
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="+",
to="wagtailimages.image",
),
),
migrations.AlterField(
model_name="imagecomparison",
name="page",
field=modelcluster.fields.ParentalKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="image_comparisons",
to="exhibits.exhibitpage",
),
),
migrations.AlterField(
model_name="imagecomparison",
name="second_image",
field=models.ForeignKey(
help_text="Second image to compare",
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="+",
to="wagtailimages.image",
),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Generated by Django 5.0.6 on 2024-09-26 18:08

from django.db import migrations


class Migration(migrations.Migration):
dependencies = [
("exhibits", "0017_alter_imagecomparison_first_image_and_more"),
]

operations = [
migrations.RemoveField(
model_name="exhibitpageleftimageonethird",
name="image",
),
migrations.RemoveField(
model_name="exhibitpageleftimageonethird",
name="link_to_next_page",
),
migrations.RemoveField(
model_name="exhibitpageleftimageonethird",
name="link_to_previous_page",
),
migrations.RemoveField(
model_name="exhibitpageleftimageonethird",
name="page_ptr",
),
migrations.RemoveField(
model_name="exhibitpagerightimageonethird",
name="image",
),
migrations.RemoveField(
model_name="exhibitpagerightimageonethird",
name="link_to_next_page",
),
migrations.RemoveField(
model_name="exhibitpagerightimageonethird",
name="link_to_previous_page",
),
migrations.RemoveField(
model_name="exhibitpagerightimageonethird",
name="page_ptr",
),
migrations.DeleteModel(
name="ExhibitPageHalfAndHalf",
),
migrations.DeleteModel(
name="ExhibitPageLeftImageOneThird",
),
migrations.DeleteModel(
name="ExhibitPageRightImageOneThird",
),
]
15 changes: 15 additions & 0 deletions exhibits/migrations/0019_delete_exhibithomeindex.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Generated by Django 5.0.6 on 2024-09-26 18:14

from django.db import migrations


class Migration(migrations.Migration):
dependencies = [
("exhibits", "0018_remove_exhibitpageleftimageonethird_image_and_more"),
]

operations = [
migrations.DeleteModel(
name="ExhibitHomeIndex",
),
]
143 changes: 28 additions & 115 deletions exhibits/models.py
Original file line number Diff line number Diff line change
@@ -22,17 +22,6 @@ class GeneralPage(Page):
]


class ExhibitHomeIndex(Page):
intro = RichTextField(blank=True, help_text="An index page for all the exhibits.")
content_panels = Page.content_panels + [FieldPanel("intro")]

def get_context(self, request):
context = super().get_context(request)
exhibitpages = self.get_children().live()
context["exhibitpages"] = exhibitpages
return context


class ExhibitHome(Page):
image = models.ForeignKey(
"wagtailimages.Image",
@@ -115,6 +104,7 @@ class ExhibitHome(Page):
FieldPanel("hero_text"),
# FieldPanel("hero_cta"),
# FieldPanel("hero_cta_link"),
FieldPanel("exhibit_display_order"),
FieldPanel("citation_text"),
# FieldPanel("tags"),
],
@@ -127,119 +117,36 @@ class ExhibitHome(Page):
]


class ExhibitPageLeftImageOneThird(Page):
image = models.ForeignKey(
"wagtailimages.Image",
null=True,
blank=False,
on_delete=models.SET_NULL,
related_name="+",
help_text="Exhibit page with one-third screen image on left",
)
image_caption = models.CharField(
max_length=500,
blank=True,
help_text="Caption for the exhibit landing page image.",
verbose_name="Image caption",
)
body = RichTextField(blank=True)
link_to_next_page = models.ForeignKey(
"wagtailcore.Page",
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name="+",
)
link_to_previous_page = models.ForeignKey(
"wagtailcore.Page",
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name="+",
)
is_end_of_exhibit = models.BooleanField(
default=False,
help_text="Is this the last page of the exhibit? If checked, yes.",
)
is_chapter_intro_page = models.BooleanField(
default=False,
help_text="Is this the first page of a chapter? If checked, yes.",
)

content_panels = Page.content_panels + [
FieldPanel("image"),
FieldPanel("image_caption"),
FieldPanel("body"),
FieldPanel("link_to_next_page"),
FieldPanel("link_to_previous_page"),
FieldPanel("is_end_of_exhibit"),
FieldPanel("is_chapter_intro_page"),
class ExhibitPage(Page):
LAYOUT_CHOICES = [
("left_image_one_third", "Left Image, One Third"),
("right_image_one_third", "Right Image, One Third"),
("left_image_two_thirds", "Left Image, Two Thirds"),
("right_image_two_thirds", "Right Image, Two Thirds"),
("half_and_half", "Half and Half"),
("full_screen", "Full Screen"),
("wide_image", "Wide Image"),
("comparison_image", "Comparison Image"),
]


class ExhibitPageRightImageOneThird(Page):
image = models.ForeignKey(
"wagtailimages.Image",
null=True,
blank=False,
on_delete=models.SET_NULL,
related_name="+",
help_text="Exhibit page with one-third screen image on right",
)
image_caption = models.CharField(
max_length=500,
blank=True,
help_text="Caption for the exhibit landing page image.",
verbose_name="Image caption",
)
body = RichTextField(blank=True)
link_to_next_page = models.ForeignKey(
"wagtailcore.Page",
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name="+",
)
link_to_previous_page = models.ForeignKey(
"wagtailcore.Page",
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name="+",
layout = models.CharField(
max_length=22,
choices=LAYOUT_CHOICES,
default="left_image_one_third",
help_text="Select the layout for this exhibit page.",
)
is_end_of_exhibit = models.BooleanField(
default=False,
help_text="Is this the last page of the exhibit? If checked, yes.",
)
is_chapter_intro_page = models.BooleanField(
default=False,
help_text="Is this the first page of a chapter? If checked, yes.",
)

content_panels = Page.content_panels + [
FieldPanel("image"),
FieldPanel("image_caption"),
FieldPanel("body"),
FieldPanel("link_to_next_page"),
FieldPanel("is_end_of_exhibit"),
FieldPanel("is_chapter_intro_page"),
FieldPanel("link_to_previous_page"),
]


class ExhibitPageHalfAndHalf(Page):
image = models.ForeignKey(
"wagtailimages.Image",
null=True,
blank=False,
on_delete=models.SET_NULL,
related_name="+",
help_text="Exhibit page with one-third screen image on right",
help_text="Image for the exhibit page.",
)
image_caption = models.CharField(
max_length=500,
blank=True,
help_text="Caption for the exhibit landing page image.",
help_text="Caption for the exhibit page image.",
verbose_name="Image caption",
)
body = RichTextField(blank=True)
@@ -267,13 +174,19 @@ class ExhibitPageHalfAndHalf(Page):
)

content_panels = Page.content_panels + [
FieldPanel("layout"),
FieldPanel("image"),
FieldPanel("image_caption"),
FieldPanel("body"),
FieldPanel("link_to_next_page"),
FieldPanel("link_to_previous_page"),
FieldPanel("is_end_of_exhibit"),
FieldPanel("is_chapter_intro_page"),
FieldPanel("link_to_previous_page"),
InlinePanel(
"image_comparisons",
label="Image Comparisons",
help_text="To use this, you must select Image Comparison from the page layout.",
),
]


@@ -296,15 +209,15 @@ class ExhibitHomeTag(TaggedItemBase):

class ImageComparison(Orderable):
page = ParentalKey(
ExhibitHome, on_delete=models.CASCADE, related_name="image_comparisons"
ExhibitPage, on_delete=models.CASCADE, related_name="image_comparisons"
)
first_image = models.ForeignKey(
"wagtailimages.Image",
null=True,
blank=False,
on_delete=models.SET_NULL,
related_name="+",
help_text="Exhibit landing page image",
help_text="First image to compare",
)
first_image_caption = models.CharField(
max_length=500,
@@ -318,7 +231,7 @@ class ImageComparison(Orderable):
blank=False,
on_delete=models.SET_NULL,
related_name="+",
help_text="Exhibit landing page image",
help_text="Second image to compare",
)
second_image_caption = models.CharField(
max_length=500,
34 changes: 0 additions & 34 deletions exhibits/templates/exhibits/exhibit_home_index.html

This file was deleted.

564 changes: 564 additions & 0 deletions exhibits/templates/exhibits/exhibit_page.html

Large diffs are not rendered by default.

102 changes: 0 additions & 102 deletions exhibits/templates/exhibits/exhibit_page_half_and_half.html

This file was deleted.

98 changes: 0 additions & 98 deletions exhibits/templates/exhibits/exhibit_page_left_image_one_third.html

This file was deleted.

This file was deleted.

0 comments on commit 73dad7f

Please sign in to comment.