-
Notifications
You must be signed in to change notification settings - Fork 231
/
relatedpages.py
30 lines (23 loc) · 951 Bytes
/
relatedpages.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"""
Add a many-to-many relationship field to relate this page to other pages.
"""
from __future__ import absolute_import, unicode_literals
from django.db import models
from django.utils.translation import ugettext_lazy as _
from feincms import extensions, settings
class Extension(extensions.Extension):
def handle_model(self):
self.model.add_to_class(
"related_pages",
models.ManyToManyField(
settings.FEINCMS_DEFAULT_PAGE_MODEL,
blank=True,
related_name="%(app_label)s_%(class)s_related",
help_text=_("Select pages that should be listed as related content."),
),
)
def handle_modeladmin(self, modeladmin):
modeladmin.extend_list("filter_horizontal", ["related_pages"])
modeladmin.add_extension_options(
_("Related pages"), {"fields": ("related_pages",), "classes": ("collapse",)}
)