コード例 #1
0
# -*- coding: utf-8 -*-
from dbgettext.registry import registry, Options
from models import Page
from django.conf import settings


class PageOptions(Options):
    attributes = ('get_title', 'get_slug')
    translate_if = {
        'published': True,
    }

    def get_path_identifier(self, obj):
        return obj.get_path()


if settings.CMS_MODERATOR:
    PageOptions.translate_if['publisher_is_draft'] = False

registry.register(Page, PageOptions)
コード例 #2
0
from dbgettext.registry import registry, Options
from models import Page
from django.conf import settings

class PageOptions(Options):
    attributes = ('get_title', 'get_slug')
    translate_if = {'published' : True,}
    def get_path_identifier(self, obj):
        return obj.get_path()

if settings.CMS_MODERATOR:
    PageOptions.translate_if['publisher_is_draft'] = False

registry.register(Page, PageOptions)
コード例 #3
0
    def __init__(self, raw, obj):
        super(PluginToken, self).__init__('plugin', raw)
        self.obj = obj

    def is_translatable(self):
        return Token.ALWAYS_TRANSLATE

    def get_key(self):
        obj, cls = self.obj.get_plugin_instance()
        return '%s-%d:%s' % (repr(cls), obj.id, re.sub('\W', '_', str(obj)))


class TextOptions(Options):
    parsed_attributes = {'body': html.lexicon}
    parent = 'page'

    from cms.plugins.text.utils import OBJ_ADMIN_RE_PATTERN

    def plugin(scanner, token):
        try:
            obj = CMSPlugin.objects.get(pk=scanner.match.groups()[0])
        except CMSPlugin.DoesNotExist:
            obj = None
        return PluginToken(token, obj)

    custom_lexicon_rules = [(OBJ_ADMIN_RE_PATTERN, plugin),]


registry.register(Text, TextOptions)
コード例 #4
0
ファイル: gettext.py プロジェクト: chemt/palanok
from dbgettext.registry import registry, Options
from models import PlatejPlugin

class PayOptions(Options):
    attributes = ('user_text',)
    parent = 'page'

registry.register(PlatejPlugin, PayOptions)
コード例 #5
0
from dbgettext.registry import registry, Options
from dbgettext.lexicons import html

from forums.models import Category, Forum


class CategoryOptions(Options):
    attributes = ('name',)

class ForumOptions(Options):
    attributes = ('name')
    parsed_attributes = {'description': html.lexicon}

registry.register(Category, CategoryOptions)
registry.register(Forum, ForumOptions)
コード例 #6
0
from dbgettext.registry import registry, Options
from dbgettext.lexicons import html
from aboutus.models import Post, Group, Person
from workshops.models import Workshop, WorkshopClass
from photos.models import Category as PhotoCategory


# PHOTOS
class PhotoCategoryOptions(Options):
    attributes = ('name', )


registry.register(PhotoCategory, PhotoCategoryOptions)


# ABOUTUS
class PostOptions(Options):
    attributes = ('title', )
    parsed_attributes = {'content': html.lexicon}


registry.register(Post, PostOptions)


class PersonOptions(Options):
    attributes = ('title', )


registry.register(Person, PersonOptions)

コード例 #7
0
from django.utils.text import slugify
from dbgettext.registry import registry, Options

from .models import Filter, FilterGroup


class FilterOptions(Options):
    attributes = ('name',)

    def get_path_identifier(self, obj):
        return obj.slug


class FilterGroupOptions(Options):
    attributes = ('name',)

    def get_path_identifier(self, obj):
        return slugify(obj.name)


registry.register(Filter, FilterOptions)
registry.register(FilterGroup, FilterGroupOptions)
コード例 #8
0
from dbgettext.registry import registry, Options
from dbgettext.lexicons import html
from django.db.models import get_model

from models import Article

class ArticleOptions(Options):
    attributes = ('name',)
    parsed_attributes = {'text': html.lexicon, 'summary':html.lexicon}

    def get_path_identifier(self, obj):
        return obj.slug


registry.register(Article, ArticleOptions)
コード例 #9
0
from dbgettext.registry import registry, Options
from dbgettext.lexicons import html

from forums.models import Category, Forum


class CategoryOptions(Options):
    attributes = ('name', )


class ForumOptions(Options):
    attributes = ('name')
    parsed_attributes = {'description': html.lexicon}


registry.register(Category, CategoryOptions)
registry.register(Forum, ForumOptions)
コード例 #10
0
from dbgettext.registry import registry, Options
from models import File


class FileOptions(Options):
    attributes = ('title', )
    parent = 'page'


registry.register(File, FileOptions)
コード例 #11
0
        super(PluginToken, self).__init__('plugin', raw)
        self.obj = obj

    def is_translatable(self):
        return Token.ALWAYS_TRANSLATE

    def get_key(self):
        obj, cls = self.obj.get_plugin_instance()
        return '%s-%d:%s' % (repr(cls), obj.id, re.sub('\W', '_', str(obj)))


class TextOptions(Options):
    parsed_attributes = {'body': html.lexicon}
    parent = 'page'

    from cms.plugins.text.utils import OBJ_ADMIN_RE_PATTERN

    def plugin(scanner, token):
        try:
            obj = CMSPlugin.objects.get(pk=scanner.match.groups()[0])
        except CMSPlugin.DoesNotExist:
            obj = None
        return PluginToken(token, obj)

    custom_lexicon_rules = [
        (OBJ_ADMIN_RE_PATTERN, plugin),
    ]


registry.register(Text, TextOptions)
コード例 #12
0
from dbgettext.registry import registry, Options
from models import Link


class LinkOptions(Options):
    attributes = ('name', 'url', 'mailto')
    parent = 'page'


registry.register(Link, LinkOptions)
コード例 #13
0
from dbgettext.registry import registry, Options
from models import Picture


class PictureOptions(Options):
    attributes = ('url', 'alt')
    parent = 'page'


registry.register(Picture, PictureOptions)