File: relatedpages.py

package info (click to toggle)
python-django-feincms 1.6.2-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 2,716 kB
  • sloc: python: 6,585; makefile: 85; sh: 18
file content (23 lines) | stat: -rw-r--r-- 762 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
"""
Add a many-to-many relationship field to relate this page to other pages.
"""

from django.db import models
from django.utils.translation import ugettext_lazy as _

from feincms.module.page.models import Page

def register(cls, admin_cls):
    cls.add_to_class('related_pages', models.ManyToManyField(Page, blank=True,
        related_name='%(app_label)s_%(class)s_related',
        null=True, help_text=_('Select pages that should be listed as related content.')))

    try:
        admin_cls.filter_horizontal.append('related_pages')
    except AttributeError:
        admin_cls.filter_horizontal = ['related_pages']

    admin_cls.fieldsets.append((_('Related pages'), {
        'fields': ('related_pages',),
        'classes': ('collapse',),
        }))