This repository was archived by the owner on Dec 26, 2023. It is now read-only.
forked from feincms/feincms
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmodels.py
More file actions
78 lines (62 loc) · 2.33 KB
/
Copy pathmodels.py
File metadata and controls
78 lines (62 loc) · 2.33 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
from django.db import models
from django.utils.translation import ugettext_lazy as _
from feincms.module.blog.models import Entry, EntryAdmin
from feincms.module.page.models import Page
from feincms.content.raw.models import RawContent
from feincms.content.image.models import ImageContent
from feincms.content.medialibrary.models import MediaFileContent
from feincms.content.application.models import ApplicationContent
from feincms.module.page.extensions.navigation import NavigationExtension, PagePretender
from feincms.content.application.models import reverse
import mptt
Page.register_templates({
'key': 'base',
'title': 'Base Template',
'path': 'base.html',
'regions': (
('main', 'Main region'),
('sidebar', 'Sidebar', 'inherited'),
),
})
Page.create_content_type(RawContent)
MediaFileContent.default_create_content_type(Page)
Page.create_content_type(ImageContent, POSITION_CHOICES=(
('default', 'Default position'),
))
Page.create_content_type(ApplicationContent, APPLICATIONS=(
('blog_urls', 'Blog'),
))
Entry.register_regions(
('main', 'Main region'),
)
Entry.create_content_type(RawContent)
Entry.create_content_type(ImageContent, POSITION_CHOICES=(
('default', 'Default position'),
))
class BlogEntriesNavigationExtension(NavigationExtension):
"""
Extended navigation for blog entries.
It would be added to 'Blog' page properties in admin.
"""
name = _('all blog entries')
def children(self, page, **kwargs):
for entry in Entry.objects.all():
yield PagePretender(
title=entry.title,
url=reverse('blog_urls/blog_entry_details', kwargs={'object_id': entry.id}),
)
Page.register_extensions('navigation')
class Category(models.Model):
name = models.CharField(max_length=20)
slug = models.SlugField()
parent = models.ForeignKey('self', blank=True, null=True, related_name='children')
class Meta:
ordering = ['name']
verbose_name = 'category'
verbose_name_plural = 'categories'
def __unicode__(self):
return self.name
mptt.register(Category)
# add m2m field to entry so it shows up in entry admin
Entry.add_to_class('categories', models.ManyToManyField(Category, blank=True, null=True))
EntryAdmin.list_filter += ('categories',)