Statistics
| Branch: | Tag: | Revision:

root / cloudcms / cms.py @ 5de4187f

History | View | Annotate | Download (6.3 kB)

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