Add image content type for blog and faq entries
[snf-cloudcms] / cloudcms / cms.py
index a11cb40..c275e19 100644 (file)
@@ -1,3 +1,37 @@
+# Copyright 2012 GRNET S.A. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or
+# without modification, are permitted provided that the following
+# conditions are met:
+#
+#   1. Redistributions of source code must retain the above
+#      copyright notice, this list of conditions and the following
+#      disclaimer.
+#
+#   2. Redistributions in binary form must reproduce the above
+#      copyright notice, this list of conditions and the following
+#      disclaimer in the documentation and/or other materials
+#      provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
+# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+# The views and conclusions contained in the software and
+# documentation are those of the authors and should not be
+# interpreted as representing official policies, either expressed
+# or implied, of GRNET S.A.
+
+
 import mptt
 
 from django import forms
@@ -20,7 +54,7 @@ from feincms.content.template.models import TemplateContent
 from feincms.content.video.models import VideoContent
 from feincms.content.richtext.models import RichTextContent
 
-from cloudcmsblog.models import Entry
+from cloudcmsresources.models import ResourcesList
 from cloudcms.content import *
 
 Page.register_extensions(
@@ -42,6 +76,7 @@ TEMPLATES = [{
     'regions': (
         ('main', 'Main region'),
         ('sidebar', 'Sidebar', 'inherited'),
+        ('bottom', 'Bottom section', 'inherited'),
         ),
     },
     {
@@ -60,6 +95,7 @@ TEMPLATES = [{
     'regions': (
         ('main', 'Main region'),
         ('sidebar', 'Sidebar', 'inherited'),
+        ('bottom', 'Bottom section', 'inherited'),
         ),
     },
     {
@@ -68,6 +104,7 @@ TEMPLATES = [{
     'path': 'cms/pages/onecol.html',
     'regions': (
         ('main', 'Main region'),
+        ('bottom', 'Bottom region'),
         ),
     },
     {
@@ -79,6 +116,23 @@ TEMPLATES = [{
         ('sidebar', 'Sidebar', 'inherited'),
         ),
     },
+    {
+    'key': 'faq',
+    'title': 'FAQ\'s template',
+    'path': 'cms/pages/faq.html',
+    'regions': (
+        ('main', 'Main region'),
+        ('sidebar', 'Sidebar', 'inherited'),
+        ),
+    },
+    {
+    'key': 'raw',
+    'title': 'Empty content template',
+    'path': 'cms/pages/empty.html',
+    'regions': (
+        ('main', 'Main region'),
+        ),
+    },
 ]
 
 # register templates
@@ -91,6 +145,7 @@ Page.create_content_type(TemplateContent)
 Page.create_content_type(TwitterFeed)
 Page.create_content_type(VideoContent)
 Page.create_content_type(VideoSection)
+Page.create_content_type(IntroButton)
 Page.create_content_type(ImageContent, POSITION_CHOICES=(
     ('default', 'Default position'),
 ))
@@ -99,23 +154,38 @@ Page.create_content_type(MediaFileContent, TYPE_CHOICES=(
   ('download', 'as download')
 ))
 Page.create_content_type(ApplicationContent, APPLICATIONS=(
-    ('cloudcmsblog', 'Cloud blog', {'urls': 'cloudcmsblog.urls'}),))
-
+    ('cloudcmsblog', 'Cloud blog', {'urls': 'cloudcmsblog.urls'}),
+    ('cloudcmsfaq', 'Cloud FAQ', {'urls': 'cloudcmsfaq.urls'}),))
 
 # cloudcms specific content registration
 Page.create_content_type(LoginForm)
 Page.create_content_type(AboutBlock)
+Page.create_content_type(ResourcesList)
 
 
-# Feincms specific registrations for our blog entry model
-Entry.register_regions(
-    ('main', _('Main content area')),
-    ('sidebar', _('Right column')),
-)
-Entry.create_content_type(RichTextContent, cleanse=False, regions=('main',))
-Entry.create_content_type(TemplateContent)
-Entry.create_content_type(VideoContent)
-Entry.create_content_type(TwitterFeed)
-Entry.create_content_type(RawContent)
-Entry.create_content_type(SectionContent, TYPE_CHOICES=(('block', 'Block'),))
+# Extra cms applications
+EXTRA_CONTENT_MODELS = []
+
+if 'cloudcmsblog' in settings.INSTALLED_APPS:
+    from cloudcmsblog.models import Entry, LatestEntries
+    EXTRA_CONTENT_MODELS.append(Entry)
+    Page.create_content_type(LatestEntries)
+
+if 'cloudcmsfaq' in settings.INSTALLED_APPS:
+    from cloudcmsfaq.models import Question
+    EXTRA_CONTENT_MODELS.append(Question)
+
+for model in EXTRA_CONTENT_MODELS:
+    # Feincms specific registrations for our blog entry model
+    model.register_regions(
+        ('main', _('Main content area')),
+        ('sidebar', _('Right column')),
+    )
+    model.create_content_type(RawContent)
+    model.create_content_type(TemplateContent)
+    model.create_content_type(SectionContent, TYPE_CHOICES=(('block', 'Block'),))
+    model.create_content_type(RichTextContent, cleanse=False, regions=('main',))
+    model.create_content_type(ImageContent, POSITION_CHOICES=(
+        ('default', 'Default position'),
+    ))