root / cloudcms / cms.py @ a13220f8
History | View | Annotate | Download (7.2 kB)
1 |
# Copyright 2012 GRNET S.A. All rights reserved.
|
---|---|
2 |
#
|
3 |
# Redistribution and use in source and binary forms, with or
|
4 |
# without modification, are permitted provided that the following
|
5 |
# conditions are met:
|
6 |
#
|
7 |
# 1. Redistributions of source code must retain the above
|
8 |
# copyright notice, this list of conditions and the following
|
9 |
# disclaimer.
|
10 |
#
|
11 |
# 2. Redistributions in binary form must reproduce the above
|
12 |
# copyright notice, this list of conditions and the following
|
13 |
# disclaimer in the documentation and/or other materials
|
14 |
# provided with the distribution.
|
15 |
#
|
16 |
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
|
17 |
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
18 |
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
19 |
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
|
20 |
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
21 |
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
22 |
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
23 |
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
24 |
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
25 |
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
26 |
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
27 |
# POSSIBILITY OF SUCH DAMAGE.
|
28 |
#
|
29 |
# The views and conclusions contained in the software and
|
30 |
# documentation are those of the authors and should not be
|
31 |
# interpreted as representing official policies, either expressed
|
32 |
# or implied, of GRNET S.A.
|
33 |
|
34 |
|
35 |
import mptt |
36 |
|
37 |
from django import forms |
38 |
from django.db import models |
39 |
from django.utils.text import capfirst |
40 |
from django.utils.translation import ugettext_lazy as _ |
41 |
|
42 |
from feincms.module.page.models import Page |
43 |
from feincms.content.raw.models import RawContent |
44 |
from feincms.content.richtext.models import RichTextContent |
45 |
from feincms.content.image.models import ImageContent |
46 |
from feincms.content.application.models import ApplicationContent |
47 |
from feincms.module.page.extensions.navigation import NavigationExtension, \ |
48 |
PagePretender
|
49 |
from feincms.content.application.models import reverse |
50 |
from feincms.content.medialibrary.v2 import MediaFileContent |
51 |
from feincms.content.section.models import SectionContent |
52 |
from feincms.content.table.models import TableContent |
53 |
from feincms.content.template.models import TemplateContent |
54 |
from feincms.content.video.models import VideoContent |
55 |
from feincms.content.richtext.models import RichTextContent |
56 |
|
57 |
from cloudcmsresources.models import ResourcesList |
58 |
from cloudcms.content import * |
59 |
|
60 |
|
61 |
Page.register_extensions( |
62 |
'changedate',
|
63 |
'datepublisher',
|
64 |
'translations',
|
65 |
'seo',
|
66 |
'symlinks',
|
67 |
'navigation',
|
68 |
'sites',
|
69 |
'titles',
|
70 |
'featured',
|
71 |
) |
72 |
|
73 |
|
74 |
# Feincms Page templates declaration
|
75 |
TEMPLATES = [{ |
76 |
'key': 'twocolwide', |
77 |
'title': 'Basic 2 columns template (left wider)', |
78 |
'path': 'cms/pages/twocolwide.html', |
79 |
'regions': (
|
80 |
('main', 'Main region'), |
81 |
('sidebar', 'Sidebar', 'inherited'), |
82 |
), |
83 |
}, |
84 |
{ |
85 |
'key': 'singlecol', |
86 |
'title': 'Basic (Top 1 col, Bottom 2 cols)', |
87 |
'path': 'cms/pages/basic1top2bottom.html', |
88 |
'regions': (
|
89 |
('top', 'Top region'), |
90 |
('bottom_left', 'Bottom left region'), |
91 |
('bottom_right', 'Bottom right region'), |
92 |
), |
93 |
}, |
94 |
{ |
95 |
'key': 'basic2top2bottom', |
96 |
'title': 'Basic (Top 2 cols, Bottom 2 cols)', |
97 |
'path': 'cms/pages/basic2top2bottom.html', |
98 |
'regions': (
|
99 |
('top_left', 'Top left region'), |
100 |
('top_right', 'Top right region'), |
101 |
('bottom_left', 'Bottom left region'), |
102 |
('bottom_right', 'Bottom right region'), |
103 |
), |
104 |
}, |
105 |
{ |
106 |
'key': 'blog', |
107 |
'title': 'Blog template', |
108 |
'path': 'cms/pages/blog.html', |
109 |
'regions': (
|
110 |
('main', 'Main region'), |
111 |
('sidebar', 'Sidebar', 'inherited'), |
112 |
), |
113 |
}, |
114 |
{ |
115 |
'key': 'userguide', |
116 |
'title': 'Userguide template', |
117 |
'path': 'cms/pages/userguide.html', |
118 |
'regions': (
|
119 |
('top', 'Top region'), |
120 |
('bottom_left', 'Bottom left region'), |
121 |
('bottom_right', 'Bottom right region'), |
122 |
), |
123 |
}, |
124 |
{ |
125 |
'key': 'faq', |
126 |
'title': 'FAQ\'s template', |
127 |
'path': 'cms/pages/faq.html', |
128 |
'regions': (
|
129 |
('top', 'Top region'), |
130 |
('bottom_left', 'Bottom left region'), |
131 |
('bottom_right', 'Bottom right region'), |
132 |
), |
133 |
}, |
134 |
{ |
135 |
'key': 'raw', |
136 |
'title': 'Empty content template', |
137 |
'path': 'cms/pages/empty.html', |
138 |
'regions': (
|
139 |
('main', 'Main region'), |
140 |
), |
141 |
}, |
142 |
{ |
143 |
'key': 'topwidetwocol', |
144 |
'title': 'Basic (Top 1 col, Middle 2 cols, Bottom 2 cols)', |
145 |
'path': 'cms/pages/topwidetwocol.html', |
146 |
'regions': (
|
147 |
('top', 'Top region'), |
148 |
('middle_left', 'Middle left region'), |
149 |
('middle_right', 'Middle right region'), |
150 |
('bottom_left', 'Bottom left region'), |
151 |
('bottom_right', 'Bottom right region'), |
152 |
), |
153 |
}, |
154 |
] |
155 |
|
156 |
# register templates
|
157 |
map(Page.register_templates, TEMPLATES)
|
158 |
|
159 |
Page.create_content_type(TextileContent) |
160 |
Page.create_content_type(IntroBlock) |
161 |
Page.create_content_type(RichTextContent) |
162 |
Page.create_content_type(RawContent) |
163 |
Page.create_content_type(SectionContent, TYPE_CHOICES=(('block', 'Block'),)) |
164 |
Page.create_content_type(TemplateContent) |
165 |
Page.create_content_type(TwitterFeed) |
166 |
Page.create_content_type(VideoContent) |
167 |
Page.create_content_type(VideoSection) |
168 |
Page.create_content_type(IntroButton) |
169 |
Page.create_content_type(ClientDownload) |
170 |
Page.create_content_type(ImageContent, POSITION_CHOICES=( |
171 |
('default', 'Default position'), |
172 |
)) |
173 |
Page.create_content_type(MediaFileContent, TYPE_CHOICES=( |
174 |
('lightbox', 'lightbox'), |
175 |
('download', 'as download') |
176 |
)) |
177 |
Page.create_content_type(ApplicationContent, APPLICATIONS=( |
178 |
('cloudcmsblog', 'Cloud blog', {'urls': 'cloudcmsblog.urls'}), |
179 |
('cloudcmsfaq', 'Cloud FAQ', {'urls': 'cloudcmsfaq.urls'}), |
180 |
('cloudcmsguide', 'Cloud user guide', {'urls': 'cloudcmsguide.urls'}),) |
181 |
) |
182 |
|
183 |
# cloudcms specific content registration
|
184 |
Page.create_content_type(LoginForm) |
185 |
Page.create_content_type(AboutBlock) |
186 |
Page.create_content_type(ResourcesList) |
187 |
Page.create_content_type(BlockColor) |
188 |
|
189 |
# Extra cms applications
|
190 |
EXTRA_CONTENT_MODELS = [] |
191 |
|
192 |
if 'cloudcmsblog' in settings.INSTALLED_APPS: |
193 |
from cloudcmsblog.models import Entry, LatestEntries |
194 |
EXTRA_CONTENT_MODELS.append(Entry) |
195 |
Page.create_content_type(LatestEntries) |
196 |
|
197 |
if 'cloudcmsfaq' in settings.INSTALLED_APPS: |
198 |
from cloudcmsfaq.models import Question |
199 |
EXTRA_CONTENT_MODELS.append(Question) |
200 |
|
201 |
if 'cloudcmsguide' in settings.INSTALLED_APPS: |
202 |
from cloudcmsguide.models import UserGuideEntry |
203 |
EXTRA_CONTENT_MODELS.append(UserGuideEntry) |
204 |
|
205 |
for model in EXTRA_CONTENT_MODELS: |
206 |
# Feincms specific registrations for our blog entry model
|
207 |
model.register_regions( |
208 |
('main', _('Main content area')), |
209 |
('sidebar', _('Right column')), |
210 |
) |
211 |
model.create_content_type(RawContent) |
212 |
model.create_content_type(TemplateContent) |
213 |
model.create_content_type(SectionContent, TYPE_CHOICES=(('block', 'Block'),)) |
214 |
model.create_content_type(RichTextContent, cleanse=False, regions=('main',)) |
215 |
model.create_content_type(ImageContent, POSITION_CHOICES=( |
216 |
('default', 'Default position'), |
217 |
)) |
218 |
|
219 |
|
220 |
Page.create_content_type(StatsBlock) |
221 |
Page.create_content_type(IntroVideo) |