def entry_list_lookup_related(entry_qs):
    entry_dict = dict((e.pk, e) for e in entry_qs)

    model = Entry.content_type_for(RichTextContent)
    if model:
        for content in model.objects.filter(
                parent__in=entry_dict.keys(),
        ).reverse():
            entry_dict[content.parent_id].first_richtext = content

    model = Entry.content_type_for(MediaFileContent)
    if model:
        for content in model.objects.filter(
                parent__in=entry_dict.keys(),
                mediafile__type='image',
        ).reverse().select_related('mediafile'):
            entry_dict[content.parent_id].first_image = content

    m2mfield = Entry._meta.get_field('categories')
    categories = Category.objects.filter(
        blogentries__in=entry_dict.keys(),
    ).extra(
        select={
            'entry_id': '%s.%s' % (
                m2mfield.m2m_db_table(), m2mfield.m2m_column_name()),
        },
    )

    for category in categories:
        entry = entry_dict[category.entry_id]
        if not hasattr(entry, 'fetched_categories'):
            entry.fetched_categories = []
        entry.fetched_categories.append(category)
    def lookup(entry_qs):
        entry_dict = dict((e.pk, e) for e in entry_qs)

        model = Entry.content_type_for(RichTextContent)
        if model:
            for content in model.objects.filter(
                parent__in=entry_dict.keys(),
            ).reverse():
                entry_dict[content.parent_id].first_richtext = content

        model = Entry.content_type_for(MediaFileContent)
        if model:
            for content in (
                model.objects.filter(
                    parent__in=entry_dict.keys(), mediafile__type="image",
                )
                .reverse()
                .select_related("mediafile")
            ):
                entry_dict[content.parent_id].first_image = content

        m2mfield = Entry._meta.get_field("categories")
        categories = Category.objects.filter(blogentries__in=entry_dict.keys(),).extra(
            select={
                "entry_id": "%s.%s"
                % (m2mfield.m2m_db_table(), m2mfield.m2m_column_name()),
            },
        )

        for category in categories:
            entry = entry_dict[category.entry_id]
            if not hasattr(entry, "fetched_categories"):
                entry.fetched_categories = []
            entry.fetched_categories.append(category)
    def lookup(entry_qs):
        entry_dict = dict((e.pk, e) for e in entry_qs)

        model = Entry.content_type_for(RichTextContent)
        if model:
            for content in model.objects.filter(parent__in=entry_dict.keys()).reverse():
                entry_dict[content.parent_id].first_richtext = content

        model = Entry.content_type_for(MediaFileContent)
        if model:
            for content in (
                model.objects.filter(parent__in=entry_dict.keys(), mediafile__type="image")
                .reverse()
                .select_related("mediafile")
            ):
                entry_dict[content.parent_id].first_image = content

        m2mfield = Entry._meta.get_field("categories")
        categories = Category.objects.filter(blogentries__in=entry_dict.keys()).extra(
            select={"entry_id": "%s.%s" % (m2mfield.m2m_db_table(), m2mfield.m2m_column_name())}
        )

        for category in categories:
            entry = entry_dict[category.entry_id]
            if not hasattr(entry, "fetched_categories"):
                entry.fetched_categories = []
            entry.fetched_categories.append(category)
    def setUpClass(cls):
        Entry.register_extensions('feincms.module.extensions.translations',)
        reset_db()
        class EntryFactory(factory.DjangoModelFactory):
            FACTORY_FOR = Entry
            is_active=True
            is_featured=False

        create_chinese_entries(EntryFactory)
    def setUpClass(cls):
        Entry.register_extensions('feincms.module.extensions.translations', )
        reset_db()

        class EntryFactory(factory.DjangoModelFactory):
            FACTORY_FOR = Entry
            is_active = True
            is_featured = False

        create_chinese_entries(EntryFactory)
Beispiel #6
0
 def testSignal(self):
     entry = Entry(author_id=1, language='de', is_active=False)
     self.assertEqual(entry.pinging, entry.SLEEPING)
     entry.save()
     self.assertEqual(entry.pinging, entry.SLEEPING)
     entry.is_active = True
     entry.save()
     self.assertEqual(entry.pinging, entry.QUEUED)
Beispiel #7
0
    def testModel(self):
        # Make sure the Entry has a blogping extension
        entry = Entry()
        self.assertTrue(hasattr(entry, 'pinging'))
        self.assertTrue(hasattr(entry, 'SLEEPING'))
        self.assertTrue(hasattr(entry, 'QUEUED'))
        self.assertTrue(hasattr(entry, 'SENT'))
        self.assertTrue(hasattr(entry, 'UNKNOWN'))

        self.assertEqual(entry.SLEEPING, 10)
        self.assertEqual(entry.pinging, entry.SLEEPING)
 def testEnvironment(self):
     # Make sure the Entry has no translation attribute
     entry = Entry()
     self.assertFalse(hasattr(entry, 'language'))
     self.assertFalse(hasattr(entry, 'translation_of'))
     entries = Entry.objects.order_by('pk')
     entry = entries[0]
     self.assertEqual(entry.pk, 1)
     self.assertEqual(entry.title, u'Entry 1')
     entry = entries[1]
     self.assertEqual(entry.pk, 2)
     self.assertEqual(entry.title, u'Eintrag 1')
 def testSignal(self):
     entry = Entry(author_id=1, language='de', is_active=False)
     self.assertEqual(entry.pinging, entry.SLEEPING)
     entry.save()
     self.assertEqual(entry.pinging, entry.SLEEPING)
     entry.is_active = True
     entry.save()
     self.assertEqual(entry.pinging, entry.QUEUED)
Beispiel #10
0
    def test_permalink_equality(self):
        urls = []
        for tzinfo in (pytz.timezone("America/Chicago"),
                       pytz.timezone("Europe/Moscow")):
            published_date = datetime.datetime(year=2012,
                                               month=3,
                                               day=3,
                                               hour=1,
                                               minute=30,
                                               tzinfo=tzinfo)
            entry = Entry.objects.create(is_active=True,
                                         author=self.author,
                                         slug='test-entry',
                                         published_on=published_date)
            urls.append(entry.get_absolute_url())
            entry.delete()
        url_chicago, url_moscow = urls
        self.assertNotEqual(url_chicago, url_moscow)
        urls = []
        for tzinfo, day, hour in [(pytz.timezone("America/Chicago"), 2, 15),
                                  (pytz.timezone("Europe/Moscow"), 3, 1)]:
            published_date = datetime.datetime(year=2012,
                                               month=3,
                                               day=day,
                                               hour=hour,
                                               minute=30,
                                               tzinfo=tzinfo)
            entry = Entry.objects.create(is_active=True,
                                         author=self.author,
                                         slug='test-entry',
                                         published_on=published_date)
            urls.append(entry.get_absolute_url())
            entry.delete()
        url_chicago, url_moscow = urls
        self.assertEqual(url_chicago, url_moscow)

        # Make sure the translation extension is not loaded for this test.
        entry = Entry()
        self.assertFalse(hasattr(entry, 'language'))
Beispiel #11
0
#
#    is_active = True
#    is_featured = True


#################################

# Elephantblog
Entry.register_extensions(
    'feincms.module.extensions.changedate',            # Creation and modification dates
    #'feincms.module.extensions.ct_tracker',            # Content type cache
    #'feincms.module.extensions.datepublisher',         # Date-based publishing
    #'feincms.module.extensions.featured',              # Simple featured flag for a page
    'feincms.module.extensions.seo',                    # Search engine optimsation
    #'feincms.module.extensions.translations',          # Page translations
    'feincms.module.page.extensions.excerpt',          # Page summary
    #'feincms.module.page.extensions.navigation',       # Navigation extensions
    'feincms.module.page.extensions.relatedpages',      # Links related content
    #'feincms.module.page.extensions.sites',            # Limit pages to sites
    #'feincms.module.page.extensions.symlinks',         # Symlinked content extension
    #'feincms.module.page.extensions.titles',           # Additional titles
    'elephantblog.extensions.blogping',
)
Entry.register_regions(
    ('main', 'Main content area'),
)
Entry.create_content_type(RichTextContent)
Entry.create_content_type(RawContent)
Entry.create_content_type(MediaFileContent, TYPE_CHOICES=(
    ('default', 'default'),
))
    {'title': 'Search page template',
    'path': 'search/search.html',
    'regions': (
        ('main', 'Main content area'),
        ),
    }
)

MEDIAFILE_TYPE_CHOICES =(
    ('default', 'default'),
)

Page.create_content_type(MediaFileContent, TYPE_CHOICES=MEDIAFILE_TYPE_CHOICES)
Page.create_content_type(RawContent)
Page.create_content_type(VideoContent)
Page.create_content_type(FormContent)
Page.create_content_type(MarkupMirrorContent)
Page.create_content_type(ApplicationContent, APPLICATIONS=(
        ('elephantblog', 'Blog', {'urls': 'elephantblog.urls'}),
        ('haystack', 'Search', {'urls': 'haystack.urls'})
))

Entry.register_extensions('feincms.module.extensions.seo',
                          'elephantblog.extensions.blogping',
)
Entry.register_regions(
    ('main', 'Main content area'),
)
Entry.create_content_type(MarkupMirrorContent, regions=('main',))
Entry.create_content_type(MediaFileContent, TYPE_CHOICES=MEDIAFILE_TYPE_CHOICES)
Entry.create_content_type(VideoContent, regions=('main',))
# coding: utf-8
from __future__ import absolute_import, unicode_literals

from django.test.testcases import TestCase
from django.test.utils import override_settings
from django.contrib import admin

from elephantblog.models import Entry

from .factories import EntryFactory, create_entries
from feincms.extensions import ExtensionModelAdmin

Entry.register_extensions('elephantblog.extensions.blogping',)


@override_settings(SITE_ID=1)
class BlogpingTest(TestCase):

    def setUp(self):
        create_entries(EntryFactory)

    def tearDown(self):
        # TODO: unregister extension
        pass

    def testModel(self):
        # Make sure the Entry has a blogping extension
        entry = Entry()
        self.assertTrue(hasattr(entry, 'pinging'))
        self.assertTrue(hasattr(entry, 'SLEEPING'))
        self.assertTrue(hasattr(entry, 'QUEUED'))
Beispiel #14
0
        ('newsletters', 'Newsletters'),
        )
    })

Page.create_content_type(RichTextContent)
Page.create_content_type(MediaFileContent, TYPE_CHOICES = (('lightbox', 'Lightbox'),
                                                           ('block','Block Image')))
Page.create_content_type(ApplicationContent, APPLICATIONS= (
        ('elephantblog.urls', 'Blog'),
        ('pagemaker.forms_urls', 'Forms'),
    ))

### BLOG ENTRIES ###

Entry.register_extensions(#'feincms.module.extensions.datepublisher',
                          'elephantblog.extensions.blogping',
                          'elephantblog.extensions.tags',)
Entry.register_regions(
    ('main', _('Main content area')),
    ('featured', _('Featured Image')),
    ('teaser', _('Teaser')),
)
Entry.create_content_type(RichTextContent, cleanse=cleanse_html, regions=('main','teaser'))
Entry.create_content_type(MediaFileContent, TYPE_CHOICES=(
    ('default', _('default')),
    ))
Entry.create_content_type(VideoContent, regions=('main', 'teaser'))

### NEWSLETTERS ###

Newsletter.register_templates({
# -*- coding:utf-8 -*-

from __future__ import absolute_import, unicode_literals

from elephantblog.models import Entry

try:
    from feincms.contents import RichTextContent, MediaFileContent
except ImportError:
    from feincms.content.richtext.models import RichTextContent
    from feincms.content.medialibrary.models import MediaFileContent


Entry.register_regions(("main", "Main content area"))

try:
    # FeinCMS 2.0
    import feincms.extensions.translations  # noqa
except ImportError:
    Entry.register_extensions("feincms.module.extensions.translations")
else:
    Entry.register_extensions("feincms.extensions.translations")

Entry.create_content_type(RichTextContent, cleanse=False, regions=("main",))
Entry.create_content_type(MediaFileContent, TYPE_CHOICES=(("default", "default"),))
Beispiel #16
0
# -*- coding:utf-8 -*-

from __future__ import absolute_import, unicode_literals

from elephantblog.models import Entry

try:
    from feincms.contents import RichTextContent
    from feincms.module.medialibrary.contents import MediaFileContent
except ImportError:  # FeinCMS<2
    from feincms.content.richtext.models import RichTextContent
    from feincms.content.medialibrary.models import MediaFileContent

Entry.register_regions(('main', 'Main content area'), )

try:
    # FeinCMS 2.0
    import feincms.extensions.translations  # noqa
except ImportError:
    Entry.register_extensions('feincms.module.extensions.translations')
else:
    Entry.register_extensions('feincms.extensions.translations')

Entry.create_content_type(RichTextContent, cleanse=False, regions=('main', ))
Entry.create_content_type(MediaFileContent,
                          TYPE_CHOICES=(('default', 'default'), ))
Beispiel #17
0
)

Page.create_content_type(RichTextContent)
Page.create_content_type(MediaFileContent, TYPE_CHOICES=(
    ('default', _('default')),
))

Page.create_content_type(FormContent)
Page.create_content_type(ApplicationContent, APPLICATIONS=(
    ('elephantblog.urls', 'Blog'),
))


Entry.register_extensions(
    'feincms.module.extensions.datepublisher',
)

Entry.register_regions(
    ('main', _('Main content area')),
)

Entry.create_content_type(
    RichTextContent,
    cleanse=feincms_cleanse.cleanse_html,
    regions=('main',)
)

Entry.create_content_type(MediaFileContent, TYPE_CHOICES=(
    ('default', _('default')),
import six
from django.utils.translation import ugettext_lazy as _
from elephantblog.models import Entry
from importlib import import_module
from leonardo.module import media, web

from .widget.blogcategories.models import BlogCategoriesWidget
from .widget.recentblogposts.models import RecentBlogPostsWidget

Entry.register_extensions('leonardo.extensions.datepublisher',
                          'leonardo.extensions.translations',
                          )

REGIONS = ('preview', 'main',)

Entry.register_regions(
    ('preview', _('Preview content area')),
    ('main', _('Main content area')),
)


def get_class_from_string(widget):
    mod = '.'.join(widget.split('.')[0:-1])
    cls_name = widget.split('.')[-1]
    return getattr(import_module(mod), cls_name)

Entry.create_content_type(
    web.models.HtmlTextWidget, regions=REGIONS, optgroup=_('Text'))
Entry.create_content_type(
    web.models.MarkupTextWidget, regions=REGIONS, optgroup=_('Text'))
Beispiel #19
0
# coding: utf-8
from __future__ import absolute_import, unicode_literals

from django.test.testcases import TestCase
from django.test.utils import override_settings
from django.contrib import admin

from elephantblog.models import Entry

from .factories import EntryFactory, create_entries
from feincms.extensions import ExtensionModelAdmin

Entry.register_extensions('elephantblog.extensions.blogping', )


@override_settings(SITE_ID=1)
class BlogpingTest(TestCase):
    def setUp(self):
        create_entries(EntryFactory)

    def tearDown(self):
        # TODO: unregister extension
        pass

    def testModel(self):
        # Make sure the Entry has a blogping extension
        entry = Entry()
        self.assertTrue(hasattr(entry, 'pinging'))
        self.assertTrue(hasattr(entry, 'SLEEPING'))
        self.assertTrue(hasattr(entry, 'QUEUED'))
        self.assertTrue(hasattr(entry, 'SENT'))
Beispiel #20
0
import six
from django.utils.translation import ugettext_lazy as _
from elephantblog.models import Entry
from importlib import import_module
from leonardo.module import media, web

from .widget.blogcategories.models import BlogCategoriesWidget
from .widget.recentblogposts.models import RecentBlogPostsWidget

Entry.register_extensions(
    'leonardo.extensions.datepublisher',
    'leonardo.extensions.translations',
)

REGIONS = (
    'preview',
    'main',
)

Entry.register_regions(
    ('preview', _('Preview content area')),
    ('main', _('Main content area')),
)


def get_class_from_string(widget):
    mod = '.'.join(widget.split('.')[0:-1])
    cls_name = widget.split('.')[-1]
    return getattr(import_module(mod), cls_name)

Beispiel #21
0
# -*- coding:utf-8 -*-

from __future__ import absolute_import, unicode_literals

from elephantblog.models import Entry

try:
    from feincms.contents import RichTextContent
    from feincms.module.medialibrary.contents import MediaFileContent
except ImportError:  # FeinCMS<2
    from feincms.content.richtext.models import RichTextContent
    from feincms.content.medialibrary.models import MediaFileContent


Entry.register_regions(
    ('main', 'Main content area'),
)

try:
    # FeinCMS 2.0
    import feincms.extensions.translations  # noqa
except ImportError:
    Entry.register_extensions('feincms.module.extensions.translations')
else:
    Entry.register_extensions('feincms.extensions.translations')

Entry.create_content_type(RichTextContent, cleanse=False, regions=('main',))
Entry.create_content_type(
    MediaFileContent,
    TYPE_CHOICES=(('default', 'default'),))
Beispiel #22
0
Page.create_content_type(RichTextContent)
Page.create_content_type(MediaFileContent, TYPE_CHOICES=MEDIA_TYPE_CHOICES)
Page.create_content_type(OembedContent, TYPE_CHOICES=OEMBED_TYPE_CHOICES)
Page.create_content_type(RawContent)
Page.create_content_type(BlogEntryListContent)
# Moodboard Content
Page.create_content_type(ShowMoodboard)


Page.create_content_type(ApplicationContent, APPLICATIONS=(
    ('elephantblog.urls', _('Blog'),),
))


# Elephantblog Setup
Entry.register_regions(
    ('main', _('Main content area')),
)

Entry.register_extensions(
    'feincms.module.extensions.translations',
)

Entry.create_content_type(RichTextContent)
Entry.create_content_type(MediaFileContent, TYPE_CHOICES=MEDIA_TYPE_CHOICES)
Entry.create_content_type(OembedContent, TYPE_CHOICES=OEMBED_TYPE_CHOICES)
Entry.create_content_type(RawContent)

# Event Content
Entry.create_content_type(VeranstaltungContent)
# -*- coding:utf-8 -*-

from __future__ import absolute_import, unicode_literals

from elephantblog.models import Entry
from feincms.content.richtext.models import RichTextContent

Entry.register_regions(
    ('main', 'Main content area'),
)
Entry.register_extensions('feincms.module.extensions.translations',)
Entry.create_content_type(RichTextContent, cleanse=False, regions=('main',))
Beispiel #24
0
    

Page.register_extensions('feincms.module.page.extensions.navigation')
Page.register_extensions('feincms.module.page.extensions.sites')
Page.register_extensions('feincms.module.extensions.seo')

# --------------------------------------------------------------
# ------------------------- BLOG -------------------------------
# --------------------------------------------------------------

if 'elephantblog' in settings.INSTALLED_APPS:
    from elephantblog.models import Entry as ElephantEntry
    from elephantblog.contents import QuoteContent
    
    ElephantEntry.register_regions(
        ('main', _('Main region')),
    )
    ElephantEntry.create_content_type(RichTextContent, cleanse=False, regions=('main',))
    ElephantEntry.create_content_type(CommentsContent)
    ElephantEntry.create_content_type(MediaFileContent, TYPE_CHOICES=MEDIA_TYPE_CHOICES)
    
    ElephantEntry.create_content_type(VideoContent)
    ElephantEntry.create_content_type(GalleryContent)
    ElephantEntry.create_content_type(QuoteContent)
    
    ElephantEntry.register_extensions('feincms.module.extensions.seo')

# ------------------------- ORGEVENT -------------------------------

if 'groupagenda' in settings.INSTALLED_APPS:
    from groupagenda.models import Event
Beispiel #25
0
# -*- coding:utf-8 -*-

from __future__ import absolute_import, unicode_literals

from elephantblog.models import Entry

try:
    from feincms.contents import RichTextContent
    from feincms.module.medialibrary.contents import MediaFileContent
except ImportError:  # FeinCMS<2
    from feincms.content.richtext.models import RichTextContent
    from feincms.content.medialibrary.models import MediaFileContent

Entry.register_regions(("main", "Main content area"), )

try:
    # FeinCMS 2.0
    import feincms.extensions.translations  # noqa
except ImportError:
    Entry.register_extensions("feincms.module.extensions.translations")
else:
    Entry.register_extensions("feincms.extensions.translations")

Entry.create_content_type(RichTextContent, cleanse=False, regions=("main", ))
Entry.create_content_type(MediaFileContent,
                          TYPE_CHOICES=(("default", "default"), ))
    def testTranslation(self):
        create_chinese_entries(EntryFactory)

        # Make sure the Entry has a translation extension
        entry = Entry()
        self.assertTrue(hasattr(entry, "language"))
        self.assertTrue(hasattr(entry, "translation_of"))

        # define the language of entry 2
        entries = Entry.objects.order_by("pk")
        entry1 = entries[0]
        self.assertEqual(entry1.pk, 1)
        self.assertEqual(entry1.title, "Entry 1")
        entry1.language = "en"
        entry1.save()
        entry2 = entries[1]
        self.assertEqual(entry2.pk, 2)
        self.assertEqual(entry2.title, "Eintrag 1")
        entry2.language = "de"
        entry2.translation_of = entry1
        entry2.save()
        entry3 = entries[2]
        entry4 = entries[3]
        self.assertEqual(entry3.language, "zh-hans")
        self.assertEqual(entry4.language, "zh-hant")

        entry = Entry.objects.get(language="de")
        self.assertEqual(entry.title, "Eintrag 1")

        with translation.override("de"):
            c = Client()
            self.assertEqual(short_language_code(), "de")
            # Test Archive URL
            response = c.get("/blog/", HTTP_ACCEPT_LANGUAGE="de")
            self.assertEqual(len(response.context["object_list"]), 1)
            self.assertEqual(response.status_code, 200)
            self.assertNotContains(response, "Entry 1")
            self.assertContains(response, "Eintrag 1")
            # test all languages override
            response = c.get("/multilang/", HTTP_ACCEPT_LANGUAGE="de")
            self.assertEqual(len(response.context["object_list"]), 4)
            self.assertEqual(response.status_code, 200)

        with translation.override("en"):
            c = Client()
            response = c.get("/blog/", HTTP_ACCEPT_LANGUAGE="en")
            self.assertEqual(short_language_code(), "en")
            self.assertEqual(len(response.context["object_list"]), 1)
            self.assertEqual(response.status_code, 200)
            self.assertContains(response, "Entry 1")
            self.assertNotContains(response, "Eintrag 1")

        with translation.override("zh-hans"):
            c = Client()
            self.assertEqual(translation.get_language(), "zh-hans")
            self.assertEqual(short_language_code(), "zh")
            response = c.get("/blog/", HTTP_ACCEPT_LANGUAGE="zh-hans")
            self.assertEqual(len(response.context["object_list"]), 1)
            self.assertEqual(response.status_code, 200)
            self.assertContains(response, "Entry 2 chinese traditional")
            self.assertNotContains(response, "Eintrag 1")

        with translation.override("zh-hant"):
            c = Client()
            self.assertEqual(translation.get_language(), "zh-hant")
            self.assertEqual(short_language_code(), "zh")
            response = c.get("/blog/", HTTP_ACCEPT_LANGUAGE="zh-hant")
            self.assertEqual(len(response.context["object_list"]), 1)
            self.assertEqual(response.status_code, 200)
            self.assertContains(response, "Entry 2 chinese simplified")
            self.assertNotContains(response, "Eintrag 1")
Beispiel #27
0
        'path': 'blog.html',
        'regions': (('main', 'Main content area'), ),
    }, {
        'title': 'Search page template',
        'path': 'search/search.html',
        'regions': (('main', 'Main content area'), ),
    })

MEDIAFILE_TYPE_CHOICES = (('default', 'default'), )

Page.create_content_type(MediaFileContent, TYPE_CHOICES=MEDIAFILE_TYPE_CHOICES)
Page.create_content_type(RawContent)
Page.create_content_type(VideoContent)
Page.create_content_type(FormContent)
Page.create_content_type(MarkupMirrorContent)
Page.create_content_type(ApplicationContent,
                         APPLICATIONS=(('elephantblog', 'Blog', {
                             'urls': 'elephantblog.urls'
                         }), ('haystack', 'Search', {
                             'urls': 'haystack.urls'
                         })))

Entry.register_extensions(
    'feincms.module.extensions.seo',
    'elephantblog.extensions.blogping',
)
Entry.register_regions(('main', 'Main content area'), )
Entry.create_content_type(MarkupMirrorContent, regions=('main', ))
Entry.create_content_type(MediaFileContent,
                          TYPE_CHOICES=MEDIAFILE_TYPE_CHOICES)
Entry.create_content_type(VideoContent, regions=('main', ))
Beispiel #28
0
# -*- coding:utf-8 -*-

from __future__ import absolute_import, unicode_literals

from elephantblog.models import Entry
from feincms.content.richtext.models import RichTextContent

Entry.register_regions(('main', 'Main content area'), )
Entry.register_extensions('feincms.module.extensions.translations', )
Entry.create_content_type(RichTextContent, cleanse=False, regions=('main', ))
Beispiel #29
0
    def testTranslation(self):
        create_chinese_entries(EntryFactory)

        # Make sure the Entry has a translation extension
        entry = Entry()
        self.assertTrue(hasattr(entry, 'language'))
        self.assertTrue(hasattr(entry, 'translation_of'))

        # define the language of entry 2
        entries = Entry.objects.order_by('pk')
        entry1 = entries[0]
        self.assertEqual(entry1.pk, 1)
        self.assertEqual(entry1.title, 'Entry 1')
        entry1.language = 'en'
        entry1.save()
        entry2 = entries[1]
        self.assertEqual(entry2.pk, 2)
        self.assertEqual(entry2.title, 'Eintrag 1')
        entry2.language = 'de'
        entry2.translation_of = entry1
        entry2.save()
        entry3 = entries[2]
        entry4 = entries[3]
        self.assertEqual(entry3.language, 'zh-hans')
        self.assertEqual(entry4.language, 'zh-hant')

        entry = Entry.objects.get(language='de')
        self.assertEqual(entry.title, 'Eintrag 1')

        with translation.override('de'):
            c = Client()
            self.assertEqual(short_language_code(), 'de')
            # Test Archive URL
            response = c.get('/blog/', HTTP_ACCEPT_LANGUAGE='de')
            self.assertEqual(len(response.context['object_list']), 1)
            self.assertEqual(response.status_code, 200)
            self.assertNotContains(response, 'Entry 1')
            self.assertContains(response, 'Eintrag 1')
            # test all languages override
            response = c.get('/multilang/', HTTP_ACCEPT_LANGUAGE='de')
            self.assertEqual(len(response.context['object_list']), 4)
            self.assertEqual(response.status_code, 200)

        with translation.override('en'):
            c = Client()
            response = c.get('/blog/', HTTP_ACCEPT_LANGUAGE='en')
            self.assertEqual(short_language_code(), 'en')
            self.assertEqual(len(response.context['object_list']), 1)
            self.assertEqual(response.status_code, 200)
            self.assertContains(response, 'Entry 1')
            self.assertNotContains(response, 'Eintrag 1')

        with translation.override('zh-hans'):
            c = Client()
            self.assertEqual(translation.get_language(), 'zh-hans')
            self.assertEqual(short_language_code(), 'zh')
            response = c.get('/blog/', HTTP_ACCEPT_LANGUAGE='zh-hans')
            self.assertEqual(len(response.context['object_list']), 1)
            self.assertEqual(response.status_code, 200)
            self.assertContains(response, 'Entry 2 chinese traditional')
            self.assertNotContains(response, 'Eintrag 1')

        with translation.override('zh-hant'):
            c = Client()
            self.assertEqual(translation.get_language(), 'zh-hant')
            self.assertEqual(short_language_code(), 'zh')
            response = c.get('/blog/', HTTP_ACCEPT_LANGUAGE='zh-hant')
            self.assertEqual(len(response.context['object_list']), 1)
            self.assertEqual(response.status_code, 200)
            self.assertContains(response, 'Entry 2 chinese simplified')
            self.assertNotContains(response, 'Eintrag 1')
    def testURLs(self):
        # Make sure the Entry has no translation attribute
        entry = Entry()
        self.assertFalse(hasattr(entry, 'language'))
        self.assertFalse(hasattr(entry, 'translation_of'))

        c = Client()
        # Test Archive URL
        response = c.get('/blog/')
        self.assertTrue(isinstance(response.context['view'],
            blogviews.ArchiveIndexView ))
        self.assertEqual(len(response.context['object_list']), 2)
        self.assertEqual(response.status_code, 200)
        self.assertContains(response, u'Entry 1')
        self.assertContains(response, u'Eintrag 1')

        # Test year archive
        response = c.get('/blog/2012/')
        self.assertTrue(isinstance(response.context['view'],
                                        blogviews.YearArchiveView ))
        self.assertEqual(len(response.context['object_list']), 2)
        self.assertEqual(response.context['view'].get_template_names(),
                         [u'elephantblog/entry_archive.html'])
        self.assertEqual(response.status_code, 200)
        self.assertContains(response, u'News for 2012')
        self.assertContains(response, u'Entry 1')
        self.assertContains(response, u'Eintrag 1')
        # No entries in 2011:
        response = c.get('/blog/2011/')
        self.assertEqual(response.status_code, 404)

        # Test month archive
        response = c.get('/blog/2012/10/')
        self.assertTrue(isinstance(response.context['view'],
                                        blogviews.MonthArchiveView ))
        self.assertEqual(len(response.context['object_list']), 1)
        self.assertEqual(response.status_code, 200)
        self.assertContains(response, u'News \nfor October 2012')
        self.assertContains(response, u'Eintrag 1')
        response = c.get('/blog/2012/08/')
        self.assertEqual(len(response.context['object_list']), 1)
        self.assertContains(response, u'News \nfor August 2012')
        self.assertContains(response, u'Entry 1')
        response = c.get('/blog/2012/06/')
        self.assertEqual(response.status_code, 404)

        # Test day archive
        response = c.get('/blog/2012/10/12/')
        self.assertTrue(isinstance(response.context['view'],
                                        blogviews.DayArchiveView ))
        self.assertEqual(len(response.context['object_list']), 1)
        self.assertEqual(response.status_code, 200)
        self.assertContains(response, u'News \n\nfor Oct. 12, 2012')
        self.assertContains(response, u'Eintrag 1')
        response = c.get('/blog/2012/08/12/')
        self.assertEqual(len(response.context['object_list']), 1)
        self.assertContains(response, u'News \n\nfor Aug. 12, 2012')
        self.assertContains(response, u'Entry 1')
        # No entries in 2011:
        response = c.get('/blog/2012/10/13/')
        self.assertEqual(response.status_code, 404)

        # Test category archive
        # assign a category to the entry
        category1 = create_category('Category 1')
        category2 = create_category('Category 2')
        entry = Entry.objects.get(slug='entry-1')
        entry.categories.add(category1)
        entry.categories.add(category2)
        entry = Entry.objects.get(slug='eintrag-1')
        entry.categories.add(category2)

        response = c.get('/blog/category/category-1/')
        self.assertEqual(response.status_code, 200)
        self.assertTrue(isinstance(response.context['view'],
            blogviews.CategoryArchiveIndexView ))
        self.assertEqual(len(response.context['object_list']), 1)
        self.assertContains(response, u'Entry 1')
        self.assertNotContains(response, u'Eintrag 1')

        response = c.get('/blog/category/category-2/')
        self.assertEqual(response.status_code, 200)
        self.assertTrue(isinstance(response.context['view'],
            blogviews.CategoryArchiveIndexView ))
        self.assertEqual(len(response.context['object_list']), 2)
        self.assertContains(response, u'Entry 1')
        self.assertContains(response, u'Eintrag 1')

        # Test detail view
        response = c.get('/blog/2012/08/12/entry-1/')
        self.assertEqual(response.status_code, 200)
        self.assertTrue(isinstance(response.context['view'],
                            blogviews.DateDetailView ))
        self.assertContains(response, u'Entry 1')
        self.assertContains(response, u'Category 1')
        self.assertContains(response, u'Category 2')
    def testTranslation(self):
        # Make sure the Entry has a translation extension
        entry = Entry()
        self.assertTrue(hasattr(entry, 'language'))
        self.assertTrue(hasattr(entry, 'translation_of'))
        # define the language of entry 2
        entries = Entry.objects.order_by('pk')
        entry1 = entries[0]
        self.assertEqual(entry1.pk, 1)
        self.assertEqual(entry1.title, u'Entry 1')
        entry1.language = 'en'
        entry1.save()
        entry2 = entries[1]
        self.assertEqual(entry2.pk, 2)
        self.assertEqual(entry2.title, u'Eintrag 1')
        entry2.language = 'de'
        entry2.translation_of = entry1
        entry2.save()
        entry3 = entries[2]
        entry4 = entries[3]
        self.assertEqual(entry3.language, 'zh-cn')
        self.assertEqual(entry4.language, 'zh-tw')

        entry = Entry.objects.get(language='de')
        self.assertEqual(entry.title, u'Eintrag 1')

        with translation.override('de'):
            c = Client()
            self.assertEqual(short_language_code(), 'de')
            # Test Archive URL
            response = c.get('/blog/', HTTP_ACCEPT_LANGUAGE='de')
            self.assertEqual(len(response.context['object_list']), 1)
            self.assertEqual(response.status_code, 200)
            self.assertNotContains(response, u'Entry 1')
            self.assertContains(response, u'Eintrag 1')
            # test all languages override
            response = c.get('/multilang/', HTTP_ACCEPT_LANGUAGE='de')
            self.assertEqual(len(response.context['object_list']), 4)
            self.assertEqual(response.status_code, 200)

        with translation.override('en'):
            response = c.get('/blog/', HTTP_ACCEPT_LANGUAGE='en')
            self.assertEqual(short_language_code(), 'en')
            self.assertEqual(len(response.context['object_list']), 1)
            self.assertEqual(response.status_code, 200)
            self.assertContains(response, u'Entry 1')
            self.assertNotContains(response, u'Eintrag 1')

        with translation.override('zh-cn'):
            self.assertEqual(translation.get_language(), 'zh-cn')
            self.assertEqual(short_language_code(), 'zh')
            response = c.get('/blog/', HTTP_ACCEPT_LANGUAGE='zh-cn')
            self.assertEqual(len(response.context['object_list']), 1)
            self.assertEqual(response.status_code, 200)
            self.assertContains(response, u'Entry 2 chinese traditional')
            self.assertNotContains(response, u'Eintrag 1')

        with translation.override('zh-tw'):
            self.assertEqual(translation.get_language(), 'zh-tw')
            self.assertEqual(short_language_code(), 'zh')
            response = c.get('/blog/', HTTP_ACCEPT_LANGUAGE='zh-tw')
            self.assertEqual(len(response.context['object_list']), 1)
            self.assertEqual(response.status_code, 200)
            self.assertContains(response, u'Entry 2 chinese simplified')
            self.assertNotContains(response, u'Eintrag 1')


# AttributeError: 'Settings' object has no attribute '_original_allowed_hosts'
# fixed in Django 1.6

# https://github.com/django/django/commit/e2b86571bfa3503fe43adfa92e9c9f4271a7a135
Beispiel #32
0
    mediafile = MediaFileForeignKey(MediaFile, blank=True, null=True)

    class Meta:
        abstract = True
        verbose_name = "Article content"

    def render(self, **kwargs):
        return render_to_string([
            "content/article/%s.html" % self.region,
            "content/article/default.html",
            ], {'content': self})


Page.register_extensions('changedate', 'navigation', 'ct_tracker')
Page.create_content_type(RichTextContent, regions=('main', 'sidebar', 'moodboard'), cleanse=True)
Page.create_content_type(MediaFileContent, TYPE_CHOICES=MEDIA_TYPE_CHOICES)
Page.create_content_type(OembedContent, DIMENSION_CHOICES=DIMENSION_CHOICES, regions=('main',))
Page.create_content_type(FormContent)
Page.create_content_type(ArticleContent)

Page.create_content_type(ApplicationContent, APPLICATIONS=(
    ('feincmsorg.app_library.urls', 'App Library'),
    ))

Entry.register_regions(
    ('main', _('Main content area')),
    )
Entry.create_content_type(RichTextContent, cleanse=True)
Entry.create_content_type(MediaFileContent, TYPE_CHOICES=MEDIA_TYPE_CHOICES)
Entry.create_content_type(OembedContent, DIMENSION_CHOICES=DIMENSION_CHOICES, regions=('main',))
# -*- coding:utf-8 -*-
from elephantblog.models import Entry
from feincms.content.richtext.models import RichTextContent

Entry.register_regions(('main', 'Main content area'), )
Entry.create_content_type(RichTextContent, cleanse=False, regions=('main', ))
Beispiel #34
0
# -*- coding:utf-8 -*-
from elephantblog.models import Entry
from feincms.content.richtext.models import RichTextContent

Entry.register_regions(
    ('main', 'Main content area'),
)
Entry.create_content_type(RichTextContent, cleanse=False, regions=('main',))
Beispiel #35
0
        verbose_name = "Article content"

    def render(self, **kwargs):
        return render_to_string([
            "content/article/%s.html" % self.region,
            "content/article/default.html",
        ], {'content': self})


Page.register_extensions('changedate', 'navigation', 'ct_tracker')
Page.create_content_type(RichTextContent,
                         regions=('main', 'sidebar', 'moodboard'),
                         cleanse=True)
Page.create_content_type(MediaFileContent, TYPE_CHOICES=MEDIA_TYPE_CHOICES)
Page.create_content_type(OembedContent,
                         DIMENSION_CHOICES=DIMENSION_CHOICES,
                         regions=('main', ))
Page.create_content_type(FormContent)
Page.create_content_type(ArticleContent)

Page.create_content_type(ApplicationContent,
                         APPLICATIONS=(('feincmsorg.app_library.urls',
                                        'App Library'), ))

Entry.register_regions(('main', _('Main content area')), )
Entry.create_content_type(RichTextContent, cleanse=True)
Entry.create_content_type(MediaFileContent, TYPE_CHOICES=MEDIA_TYPE_CHOICES)
Entry.create_content_type(OembedContent,
                          DIMENSION_CHOICES=DIMENSION_CHOICES,
                          regions=('main', ))
from django.conf import settings
from django.utils.translation import ugettext as _

from feincms.content.raw.models import RawContent
from feincms.content.richtext.models import RichTextContent
from feincms.content.medialibrary.models import MediaFileContent
from feincms_oembed.contents import OembedContent

from elephantblog.models import Entry


Entry.register_extensions(
    'feincms.module.extensions.translations',
    'news.linkextension',
    'news.locationextension',
)

Entry.register_regions(
    ('main', _('Main content area')),
    ('preview', _('Preview')),
    ('cover', _('Cover image')),
)

Entry.create_content_type(RichTextContent,
    regions=('main', 'preview', 'cover',)
)

Entry.create_content_type(MediaFileContent, TYPE_CHOICES=(
    ('default', _('default')),
))
Beispiel #37
0
from django.utils.translation import ugettext_lazy as _

from feincms.content.richtext.models import RichTextContent
from feincms.content.medialibrary.models import MediaFileContent
import feincms_cleanse

from elephantblog.models import Entry

Entry.register_extensions(
    'feincms.module.extensions.translations',
    'feincms.module.extensions.datepublisher',
)

Entry.register_regions(
    ('main', _('Main content area')),
    ('teaser', _('Blog entry teaser')),
)

Entry.create_content_type(RichTextContent,
                          cleanse=feincms_cleanse.cleanse_html,
                          regions=(
                              'main',
                              'teaser',
                          ))

Entry.create_content_type(MediaFileContent,
                          TYPE_CHOICES=(('default', _('default')), ))
Beispiel #38
0
#    FACTORY_FOR = Writing
#
#    is_active = True
#    is_featured = True

#################################

# Elephantblog
Entry.register_extensions(
    'feincms.module.extensions.changedate',  # Creation and modification dates
    #'feincms.module.extensions.ct_tracker',            # Content type cache
    #'feincms.module.extensions.datepublisher',         # Date-based publishing
    #'feincms.module.extensions.featured',              # Simple featured flag for a page
    'feincms.module.extensions.seo',  # Search engine optimsation
    #'feincms.module.extensions.translations',          # Page translations
    'feincms.module.page.extensions.excerpt',  # Page summary
    #'feincms.module.page.extensions.navigation',       # Navigation extensions
    'feincms.module.page.extensions.relatedpages',  # Links related content
    #'feincms.module.page.extensions.sites',            # Limit pages to sites
    #'feincms.module.page.extensions.symlinks',         # Symlinked content extension
    #'feincms.module.page.extensions.titles',           # Additional titles
    'elephantblog.extensions.blogping',
)
Entry.register_regions(('main', 'Main content area'), )
Entry.create_content_type(RichTextContent)
Entry.create_content_type(RawContent)
Entry.create_content_type(MediaFileContent,
                          TYPE_CHOICES=(('default', 'default'), ))

#def highlight_pygments(page, request, response):
#    import pdb; pdb.set_trace()
Beispiel #39
0

#
# elephantblog
#
from elephantblog.models import Entry

# extensions are declared in the reverse order that they appear in the admin
# NOTE: the 'seo' extension must be defined AFTER the 'translations' extension,
# otherwise it generates a django error
Entry.register_extensions(
    # 'feincms.extensions.featured',
    'feincms.module.extensions.changedate',
    # 'feincms.module.extensions.datepublisher',
    'feincms.module.extensions.translations',
    'feincms.module.page.extensions.excerpt',
    'feincms.module.extensions.seo',
    'feincms.module.page.extensions.titles',
    'elephantblog.extensions.blogping',
    'elephantblog.extensions.tags',
)
Entry.register_regions(
    ('main', _('Main region')),
)
Entry.create_content_type(
    RichTextContent,
    cleanse=feincms_cleanse.cleanse_html, 
    regions=('main',)
)
Entry.create_content_type(
    MediaFileContent,