kopia lustrzana https://github.com/wagtail/wagtail
Add alias_of field to Page
rodzic
77610d1e64
commit
17f63f0efc
|
@ -123,6 +123,12 @@ Database fields
|
|||
|
||||
The date/time when the page was locked.
|
||||
|
||||
.. attribute:: alias_of
|
||||
|
||||
(foreign key to another page)
|
||||
|
||||
If set, this page is an alias of the page referenced in this field.
|
||||
|
||||
Methods and properties
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
# Generated by Django 3.0.9 on 2020-08-04 12:38
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('wagtailcore', '0057_page_locale_fields_notnull'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='page',
|
||||
name='alias_of',
|
||||
field=models.ForeignKey(blank=True, editable=False, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='aliases', to='wagtailcore.Page'),
|
||||
),
|
||||
]
|
|
@ -760,6 +760,18 @@ class Page(AbstractPage, index.Indexed, ClusterableModel, metaclass=PageBase):
|
|||
editable=False
|
||||
)
|
||||
|
||||
# If non-null, this page is an alias of the linked page
|
||||
# This means the page is kept in sync with the live version
|
||||
# of the linked pages and is not editable by users.
|
||||
alias_of = models.ForeignKey(
|
||||
'self',
|
||||
on_delete=models.SET_NULL,
|
||||
null=True,
|
||||
blank=True,
|
||||
editable=False,
|
||||
related_name='aliases',
|
||||
)
|
||||
|
||||
search_fields = [
|
||||
index.SearchField('title', partial_match=True, boost=2),
|
||||
index.AutocompleteField('title'),
|
||||
|
@ -2255,11 +2267,13 @@ class Page(AbstractPage, index.Indexed, ClusterableModel, metaclass=PageBase):
|
|||
* ``locked_at``
|
||||
* ``latest_revision_created_at``
|
||||
* ``first_published_at``
|
||||
* ``alias_of``
|
||||
"""
|
||||
|
||||
obj = self.specific_class.from_json(content_json)
|
||||
|
||||
# These should definitely never change between revisions
|
||||
obj.id = self.id
|
||||
obj.pk = self.pk
|
||||
obj.content_type = self.content_type
|
||||
|
||||
|
@ -2285,6 +2299,7 @@ class Page(AbstractPage, index.Indexed, ClusterableModel, metaclass=PageBase):
|
|||
obj.first_published_at = self.first_published_at
|
||||
obj.translation_key = self.translation_key
|
||||
obj.locale = self.locale
|
||||
obj.alias_of_id = self.alias_of_id
|
||||
|
||||
return obj
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue