File: featured.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 (17 lines) | stat: -rw-r--r-- 512 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
"""
Add a "featured" field to objects so admins can better direct top content.
"""

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

def register(cls, admin_cls):
    cls.add_to_class('featured', models.BooleanField(_('featured')))

    if hasattr(cls, 'cache_key_components'):
        cls.cache_key_components.append(lambda page: page.featured)

    admin_cls.fieldsets.append((_('Featured'), {
        'fields': ('featured',),
        'classes': ('collapse',),
        }))