当前位置: 首页>>代码示例>>Python>>正文


Python models.Page类代码示例

本文整理汇总了Python中feincms.module.page.models.Page的典型用法代码示例。如果您正苦于以下问题:Python Page类的具体用法?Python Page怎么用?Python Page使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Page类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

    def setUp(self):
        Page.register_templates({
            'key': 'base',
            'title': 'Standard template',
            'path': 'feincms_base.html',
            'regions': (
                ('main', 'Main content area'),
                ('sidebar', 'Sidebar', 'inherited'),
            ),
        })
        self.site_1 = Site.objects.all()[0]

        # create a bunch of pages
        en = self.create_default_page_set(language='en')
        de = self.create_default_page_set(language='de', title='Testseite')
        de.translation_of = en
        de.save()
        de.parent.translation_of = en.parent
        de.parent.save()
        self.page_de = de.parent
        self.page_en = en.parent

        if hasattr(translation, 'LANGUAGE_SESSION_KEY'):
            self.language_session_key = translation.LANGUAGE_SESSION_KEY
        else:
            # Django 1.6
            self.language_session_key = django_settings.LANGUAGE_COOKIE_NAME
开发者ID:ixc,项目名称:feincms,代码行数:27,代码来源:test_extensions.py

示例2: import_structure

def import_structure(f, root_id=None):
    """docstring for import_structure"""
    parents = {}
    if root_id:
        parents[0] = Page.objects.get(id=root_id)
    else:
        parents[0] = None
    kwargs = {
        'active': True,
        'in_navigation': True,
    }
    for line in f:
        match = re.match(r"^(#+) (\{[^)]*} )?(.*)$", unicode(line))
        if match:
            level = len(match.group(1))
            opts = match.group(2)
            if opts:
                js = json.loads(opts)
                kwargs.update(**dict([(str(k), v) for k, v in js.items()]))
            title = match.group(3)
            parent = parents[level-1]
            parent_page = Page.objects.get(pk=parent.pk) if parent else None
            p = Page(
                title=title,
                slug=slugify(title),
                parent=parent_page,
                **kwargs
            )
            p.save()
            parents[level] = p
            print('adding FeinCMS page: %s' % title)
开发者ID:baronvonvaderham,项目名称:feincms-feincmsext,代码行数:31,代码来源:structure.py

示例3: setUp

    def setUp(self):
        Page.register_templates(
            {
                "key": "base",
                "title": "Standard template",
                "path": "feincms_base.html",
                "regions": (
                    ("main", "Main content area"),
                    ("sidebar", "Sidebar", "inherited"),
                ),
            }
        )
        self.site_1 = Site.objects.all()[0]

        # create a bunch of pages
        en = self.create_default_page_set(language="en")
        de = self.create_default_page_set(language="de", title="Testseite")
        de.translation_of = en
        de.save()
        de.parent.translation_of = en.parent
        de.parent.save()
        self.page_de = de.parent
        self.page_en = en.parent

        if hasattr(translation, "LANGUAGE_SESSION_KEY"):
            self.language_session_key = translation.LANGUAGE_SESSION_KEY
        else:
            # Django 1.6
            self.language_session_key = django_settings.LANGUAGE_COOKIE_NAME
开发者ID:feincms,项目名称:feincms,代码行数:29,代码来源:test_extensions.py

示例4: test_pages_l10n_template

def test_pages_l10n_template():
    parent = Page(title="Parent Title", slug="parent-slug")
    page = Page(title="Page Title", slug="page-slug")
    page.parent = parent
    parent_entry = models.RichTextEntry(text="<p>Parent Text</p>")
    entry = models.RichTextEntry(text="<p>Page Text</p>")
    parent.content.all_of_type = lambda content_type: [parent_entry]
    page.content.all_of_type = lambda content_type: [entry]
    l10n_template = utils.pages_l10n_template([parent, page])
    assert "Page path: /parent-slug/\n" in l10n_template
    assert "Page path: /parent-slug/page-slug/\n" in l10n_template
    assert "{% blocktrans trimmed %}\nParent Title\n{% endblocktrans %}" in l10n_template
    assert "{% blocktrans trimmed %}\nPage Title\n{% endblocktrans %}" in l10n_template
    assert "{% blocktrans trimmed %}\n<p>Parent Text</p>\n{% endblocktrans %}" in l10n_template
    assert "{% blocktrans trimmed %}\n<p>Page Text</p>\n{% endblocktrans %}" in l10n_template
开发者ID:Osmose,项目名称:masterfirefoxos,代码行数:15,代码来源:test_utils.py

示例5: save_content

def save_content(request):
    """
    content save handler
    Returns a HttpResponse whose content is JSON to tell if the operation succeeded.
    """
    result = {"result": False}

    if request.method == "POST":
        if request.POST["content"]:
            page_items = loads(request.POST["content"])

            for content_key, item in page_items.iteritems():
                # TODO: move to model/form cleaning

                content = item["value"]
                if settings.FEINCMS_TIDY_HTML:
                    content, errors, warnings = get_object(settings.FEINCMS_TIDY_FUNCTION)(content)

                matches = re.search("^page-page-richtextcontent-(\d+)-(\d+)$", content_key)
                if matches:
                    page_id, content_id = matches.group(1), matches.group(2)

                    # TODO: replace with more flexible solution (not tied to the RichTextContent model), as done in _frontend_editing_view
                    RTC = Page.content_type_for(RichTextContent)
                    rtc = RTC.objects.get(id=content_id, parent__id=page_id)
                    rtc.text = content

                    rtc.save()
                    # TODO: this should be done differently; being able to handle every page-item separartly (see formsets)
                    result = {"result": True}

    return HttpResponse(dumps(result), content_type="application/json")
开发者ID:MechanisM,项目名称:feincms-mercury,代码行数:32,代码来源:views.py

示例6: setUp

    def setUp(self):
        u = User(username="test", is_active=True, is_staff=True, is_superuser=True)
        u.set_password("test")
        u.save()

        Page.register_templates(
            {
                "key": "base",
                "title": "Standard template",
                "path": "feincms_base.html",
                "regions": (("main", "Main content area"), ("sidebar", "Sidebar", "inherited")),
            },
            {
                "key": "theother",
                "title": "This actually exists",
                "path": "base.html",
                "regions": (("main", "Main content area"), ("sidebar", "Sidebar", "inherited")),
            },
        )
开发者ID:nicoechaniz,项目名称:feincms,代码行数:19,代码来源:__init__.py

示例7: test_14_richtext

    def test_14_richtext(self):
        # only create the content type to test the item editor
        # customization hooks
        tmp = Page._feincms_content_types[:]
        type = Page.create_content_type(RichTextContent, regions=('notexists',))
        Page._feincms_content_types = tmp

        from django.utils.safestring import SafeData
        obj = type()
        obj.text = 'Something'
        self.assertTrue(isinstance(obj.render(), SafeData))
开发者ID:aweakley,项目名称:feincms,代码行数:11,代码来源:base.py

示例8: setUp

    def setUp(self):
        Page.register_templates({
            'key': 'base',
            'title': 'Standard template',
            'path': 'feincms_base.html',
            'regions': (
                ('main', 'Main content area'),
                ('sidebar', 'Sidebar', 'inherited'),
            ),
        })
        self.site_1 = Site.objects.all()[0]

        # create a bunch of pages
        en = self.create_default_page_set(language='en')
        de = self.create_default_page_set(language='de', title=u'Testseite')
        de.translation_of = en
        de.save()
        de.parent.translation_of = en.parent
        de.parent.save()
        self.page_de = de.parent
        self.page_en = en.parent
开发者ID:mjog,项目名称:feincms,代码行数:21,代码来源:test_extensions.py

示例9: setUp

    def setUp(self):
        u = User(username='test', is_active=True, is_staff=True, is_superuser=True)
        u.set_password('test')
        u.save()

        Page.register_templates({
                'key': 'base',
                'title': 'Standard template',
                'path': 'feincms_base.html',
                'regions': (
                    ('main', 'Main content area'),
                    ('sidebar', 'Sidebar', 'inherited'),
                    ),
                }, {
                'key': 'theother',
                'title': 'This actually exists',
                'path': 'base.html',
                'regions': (
                    ('main', 'Main content area'),
                    ('sidebar', 'Sidebar', 'inherited'),
                    ),
                })
开发者ID:aweakley,项目名称:feincms,代码行数:22,代码来源:base.py

示例10: import_structure

def import_structure(f, root_id=None):
    """docstring for import_structure"""
    parents = {}
    if root_id:
        parents[0] = Page.objects.get(id=root_id)
    else:
        parents[0] = None

    for line in f:
        match = re.match(r"^(#+) (.*)$", line)
        if match:
            level = len(match.group(1))
            title = match.group(2)
            parent = parents[level - 1]
            parent_page = Page.objects.get(pk=parent.pk) if parent else None
            p = Page(active=True, title=title, slug=slugify(title), in_navigation=True, parent=parent_page)
            for field in ("navigation_type",):
                if parent and parent.__dict__.get(field, None):
                    p.__dict__[field] = parent.__dict__[field]
            p.save()
            parents[level] = p
            print("adding FeinCMS page: %s" % title)
开发者ID:Gwildor,项目名称:feincms-feincmsext,代码行数:22,代码来源:structure.py

示例11: test_18_default_render_method

    def test_18_default_render_method(self):
        """
        Test the default render() behavior of selecting render_<region> methods
        to do the (not so) heavy lifting.
        """

        class Something(models.Model):
            class Meta:
                abstract = True

            def render_main(self):
                return u'Hello'

        # do not register this model in the internal FeinCMS bookkeeping structures
        tmp = Page._feincms_content_types[:]
        type = Page.create_content_type(Something, regions=('notexists',))
        Page._feincms_content_types = tmp

        s = type(region='main', ordering='1')

        self.assertEqual(s.render(), 'Hello')
开发者ID:aweakley,项目名称:feincms,代码行数:21,代码来源:base.py

示例12: _

#!/usr/bin/env python
# -*- coding: utf-8 -*-
from django.utils.translation import ugettext_lazy as _
from django.db import models
from django.template.loader import render_to_string
#from django.contrib.markup.templatetags.markup import restructuredtext
from feincms.module.page.models import Page
from feincms.content.richtext.models import RichTextContent
from feincms.content.medialibrary.models import MediaFileContent

Page.register_templates(
    {
    'key' : 'base',
    'title': _(u'Standard template'),
    'path': 'cms_base.html',
    'regions': (
        ('main', _(u'Main content area')),
    ),
    },
    )
Page.register_extensions('changedate', 'translations', )

#class ReSTContent(models.Model):
#    content = models.TextField()
#
#    class Meta:
#        abstract = True
#        verbose_name = _(u'ReStructured Text')
#        verbose_name_plural = _(u'ReStructured Texts')
#
#    def render(self, **kwargs):
开发者ID:Bearcode,项目名称:playground,代码行数:31,代码来源:models.py

示例13: _

from django.utils.translation import ugettext_lazy as _
from feincms.module.page.models import Page
from feincms.content.application.models import ApplicationContent
from feincms.content.richtext.models import RichTextContent
from feincms.content.raw.models import RawContent
from feincms.content.file.models import FileContent
from gform.content import FormContent
#from gbase.request_processors import authenticated_request_processor


# Register page extensions
Page.register_extensions(
    'feincms.module.extensions.datepublisher',
    'feincms.module.extensions.changedate',
    'feincms.module.page.extensions.navigation',
    'feincms.module.extensions.seo',
    'feincms.module.page.extensions.symlinks',
    'feincms.module.page.extensions.titles',
    'gbase.extensions.menu_class',
    #'feincms.module.page.extensions.translations',
)

# Loading templates for Page models
Page.register_templates(
    {
        'key': 'index',
        'title': _('Index Page'),
        'path': 'layout_index.html',
        'regions': (
            ('main', _('Main content area')),
        ),
    },
开发者ID:indexofire,项目名称:gork,代码行数:32,代码来源:models.py

示例14: ExampleCMSBase2

ExampleCMSBase.register_regions(('region', 'region title'), ('region2', 'region2 title'))


class ExampleCMSBase2(Base):
        pass

ExampleCMSBase2.register_regions(('region', 'region title'),
        ('region2', 'region2 title'))

Page.register_extensions(
    'feincms.module.extensions.datepublisher',
    'feincms.module.extensions.translations',
    'feincms.module.extensions.ct_tracker',
    'feincms.module.extensions.seo',
    'feincms.module.extensions.changedate',
    'feincms.module.extensions.seo',  # duplicate
    'feincms.module.page.extensions.navigation',
    'feincms.module.page.extensions.symlinks',
    'feincms.module.page.extensions.titles',
    )
Page.create_content_type(ContactFormContent, form=ContactForm)
Page.create_content_type(FileContent)
Page.register_request_processor(processors.etag_request_processor)
Page.register_response_processor(processors.etag_response_processor)
Page.register_response_processor(processors.debug_sql_queries_response_processor())


class BlogTestCase(TestCase):
    def setUp(self):
        u = User(username='test', is_active=True, is_staff=True, is_superuser=True)
开发者ID:balmaster,项目名称:feincms,代码行数:30,代码来源:test_stuff.py

示例15: _

Page.register_templates(
    {
        'title': _('Topic Page'),
        'path': 'page_layout_templates/topic_page.html',
        'regions': (
            ('header_block', _('Header Block')),
            ('title_banner', _('Title Banner')),
            ('rich_text_content', _('Rich Text Content')),
            ('featured', _('Featured')),
            ('icon-featured-panes', _('Icon Featured Panes')),
            ('main_content', _('Main Content')),
            ('parallax_box', _('Parallax Box')),
            ('additional_content', _('Additional Content')),
            ('sponsors', _('Sponsors')),
        )},
    {
        'title': _('Detail Page'),
        'path': 'page_layout_templates/detail_page.html',
        'regions': (
            ('header_block', _('Header Block')),
            ('rich-text-left-column', _('Left Column Text Block')),
            ('medium-image-right-column', _('Right Column Image')),
            ('featured', _('Featured')),
            ('main_content', _('Main Content')),
            ('call_to_action', _('Parallax Box')),
            ('additional_content', _('Additional Content')),
            ('rich-text-left-column-2', _('Left Column Text Block 2')),
            ('medium-image-right-column-2', _('Right Column Image 2')),
            ('sponsors', _('Sponsors')),
        )},
    {
        'title': _('Home Page'),
        'path': 'page_layout_templates/home_page.html',
        'regions': (
            ('header_block', _('Header Block')),
            ('main_slider', _('Main Slider')),
            ('call_to_action', _('Call To Action Bar')),
            ('featured', _('Featured')),
            ('rich-text-left-column', _('Left Column Text Block')),
            ('medium-image-right-column', _('Right Column Image')),
            ('parallax_box_1', _('Parallax Box 1')),
            ('about', _('About')),
            ('parallax_box_2', _('Parallax Box 2')),
            ('sponsors', _('Sponsors')),
        )},
    {
        'title': _('Two-Column Content Page'),
        'path': 'page_layout_templates/simple_page.html',
        'regions': (
            ('header_block', _('Header Block')),
            ('title_banner', _('Title Banner')),
            ('content', _('Two-Column Content')),
            ('call_to_action', _('Call To Action Bar')),
            ('sponsors', _('Sponsors')),
        )},
    {
        'title': _('Flickr Gallery Page'),
        'path': 'page_layout_templates/flickr_gallery.html',
        'regions': (
            ('header_block', _('Header Block')),
            ('title_banner', _('Title Banner')),
            ('rich_text_content', _('Rich Text Block')),
            ('flickr_gallery', _('Flickr Gallery')),
            ('videos', _('Youtube Videos')),
            ('sponsors', _('Sponsors')),
        )},
    {
        'title': _('Rich Text Page'),
        'path': 'page_layout_templates/plain_text_page.html',
        'regions': (
            ('header_block', _('Header Block')),
            ('title_banner', _('Title Banner')),
            ('rich_text_content', _('Content')),
            ('sponsors', _('Sponsors')),
        )},
    {
        'title': _('Video Gallery Page'),
        'path': 'page_layout_templates/video_gallery.html',
        'regions': (
            ('header_block', _('Header Block')),
            ('title_banner', _('Title Banner')),
            ('content', _('Content')),
            ('video-column-1', _('Video Column 1')),
            ('video-column-2', _('Video Column 2')),
            ('video-column-3', _('Video Column 3')),
            ('additional_content', _('Additional Content')),
            ('sponsors', _('Sponsors')),
        )},
    {
        'title': _('Pricing Table Page'),
        'path': 'page_layout_templates/pricing_page.html',
        'regions': (
            ('header_block', _('Header Block')),
            ('title_banner', _('Title Banner')),
            ('rich_text_1', _('Rich Text Content 1')),
            ('pricing_table', _('Pricing Table')),
            ('rich_text_2', _('Rich Text Content 2')),
            ('sponsors', _('Sponsors')),
        )},
    {
#.........这里部分代码省略.........
开发者ID:AASHE,项目名称:aashe-conference,代码行数:101,代码来源:models.py


注:本文中的feincms.module.page.models.Page类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。