Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GenericRelation to revisions and workflow states #477

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions bakerydemo/base/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import unicode_literals

from django.contrib.contenttypes.fields import GenericRelation
from django.db import models
from django.utils.translation import gettext as _
from modelcluster.fields import ParentalKey
Expand Down Expand Up @@ -67,6 +68,22 @@ class Person(
related_name="+",
)

workflow_states = GenericRelation(
"wagtailcore.WorkflowState",
content_type_field="base_content_type",
object_id_field="object_id",
related_query_name="person",
for_concrete_model=False,
)

revisions = GenericRelation(
"wagtailcore.Revision",
content_type_field="base_content_type",
object_id_field="object_id",
related_query_name="person",
for_concrete_model=False,
)

panels = [
MultiFieldPanel(
[
Expand Down Expand Up @@ -163,6 +180,14 @@ class FooterText(

body = RichTextField()

revisions = GenericRelation(
"wagtailcore.Revision",
content_type_field="base_content_type",
object_id_field="object_id",
related_query_name="footer_text",
for_concrete_model=False,
)

panels = [
FieldPanel("body"),
PublishingPanel(),
Expand Down
17 changes: 17 additions & 0 deletions bakerydemo/breads/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django import forms
from django.contrib.contenttypes.fields import GenericRelation
from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator
from django.db import models
from modelcluster.fields import ParentalManyToManyField
Expand Down Expand Up @@ -42,6 +43,14 @@ class in wagtail_hooks.py. This allows us to customize the admin interface for t

name = models.CharField(max_length=255)

revisions = GenericRelation(
"wagtailcore.Revision",
content_type_field="base_content_type",
object_id_field="object_id",
related_query_name="bread_ingredient",
for_concrete_model=False,
)

panels = [
FieldPanel("name"),
]
Expand All @@ -66,6 +75,14 @@ class in wagtail_hooks.py. This allows us to customize the admin interface for t

title = models.CharField(max_length=255)

revisions = GenericRelation(
"wagtailcore.Revision",
content_type_field="base_content_type",
object_id_field="object_id",
related_query_name="bread_type",
for_concrete_model=False,
)

panels = [
FieldPanel("title"),
]
Expand Down
Loading