Initial commit
[snf-cloudcms] / cloudcms / cms.py
1 import mptt
2
3 from django import forms
4 from django.db import models
5 from django.utils.text import capfirst
6 from django.utils.translation import ugettext_lazy as _
7
8 from feincms.module.page.models import Page
9 from feincms.content.raw.models import RawContent
10 from feincms.content.richtext.models import RichTextContent
11 from feincms.content.image.models import ImageContent
12 from feincms.content.application.models import ApplicationContent
13 from feincms.module.page.extensions.navigation import NavigationExtension, \
14         PagePretender
15 from feincms.content.application.models import reverse
16 from feincms.content.medialibrary.v2 import MediaFileContent
17 from feincms.content.section.models import SectionContent
18 from feincms.content.table.models import TableContent
19 from feincms.content.template.models import TemplateContent
20 from feincms.content.video.models import VideoContent
21 from feincms.content.richtext.models import RichTextContent
22
23 from cloudcmsblog.models import Entry
24 from cloudcms.content import *
25
26 Page.register_extensions(
27     'changedate',
28     'datepublisher',
29     'translations',
30     'seo',
31     'symlinks',
32     'navigation',
33     'sites',
34     'titles'
35 )
36
37 # Feincms Page templates declaration
38 TEMPLATES = [{
39     'key': 'basic',
40     'title': 'Basic 2 columns template',
41     'path': 'cms/pages/page.html',
42     'regions': (
43         ('main', 'Main region'),
44         ('sidebar', 'Sidebar', 'inherited'),
45         ),
46     },
47     {
48     'key': 'twocolwide',
49     'title': 'Basic 2 columns template (wider)',
50     'path': 'cms/pages/twocolwide.html',
51     'regions': (
52         ('main', 'Main region'),
53         ('sidebar', 'Sidebar', 'inherited'),
54         ),
55     },
56     {
57     'key': 'intro',
58     'title': 'Intro page Template',
59     'path': 'cms/pages/intro.html',
60     'regions': (
61         ('main', 'Main region'),
62         ('sidebar', 'Sidebar', 'inherited'),
63         ),
64     },
65     {
66     'key': 'singlecol',
67     'title': 'Basic 1 column template',
68     'path': 'cms/pages/onecol.html',
69     'regions': (
70         ('main', 'Main region'),
71         ),
72     },
73     {
74     'key': 'blog',
75     'title': 'Blog template',
76     'path': 'cms/pages/blog.html',
77     'regions': (
78         ('main', 'Main region'),
79         ('sidebar', 'Sidebar', 'inherited'),
80         ),
81     },
82 ]
83
84 # register templates
85 map(Page.register_templates, TEMPLATES)
86
87 Page.create_content_type(RichTextContent)
88 Page.create_content_type(RawContent)
89 Page.create_content_type(SectionContent, TYPE_CHOICES=(('block', 'Block'),))
90 Page.create_content_type(TemplateContent)
91 Page.create_content_type(TwitterFeed)
92 Page.create_content_type(VideoContent)
93 Page.create_content_type(VideoSection)
94 Page.create_content_type(ImageContent, POSITION_CHOICES=(
95     ('default', 'Default position'),
96 ))
97 Page.create_content_type(MediaFileContent, TYPE_CHOICES=(
98   ('lightbox', 'lightbox'),
99   ('download', 'as download')
100 ))
101 Page.create_content_type(ApplicationContent, APPLICATIONS=(
102     ('cloudcmsblog', 'Cloud blog', {'urls': 'cloudcmsblog.urls'}),))
103
104
105 # cloudcms specific content registration
106 Page.create_content_type(LoginForm)
107 Page.create_content_type(AboutBlock)
108
109
110 # Feincms specific registrations for our blog entry model
111 Entry.register_regions(
112     ('main', _('Main content area')),
113     ('sidebar', _('Right column')),
114 )
115 Entry.create_content_type(RichTextContent, cleanse=False, regions=('main',))
116 Entry.create_content_type(TemplateContent)
117 Entry.create_content_type(VideoContent)
118 Entry.create_content_type(TwitterFeed)
119 Entry.create_content_type(RawContent)
120 Entry.create_content_type(SectionContent, TYPE_CHOICES=(('block', 'Block'),))
121