forked from matthiask/feincms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfeatured.py
More file actions
24 lines (17 loc) · 734 Bytes
/
Copy pathfeatured.py
File metadata and controls
24 lines (17 loc) · 734 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"""
Add a "featured" field to objects so admins can better direct top content.
"""
from __future__ import absolute_import, unicode_literals
from django.db import models
from django.utils.translation import ugettext_lazy as _
from feincms import extensions
class Extension(extensions.Extension):
def handle_model(self):
self.model.add_to_class('featured', models.BooleanField(_('featured')))
if hasattr(self.model, 'cache_key_components'):
self.model.cache_key_components.append(lambda page: page.featured)
def handle_modeladmin(self, modeladmin):
modeladmin.add_extension_options(_('Featured'), {
'fields': ('featured',),
'classes': ('collapse',),
})