# -*- 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)
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)
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)
from dbgettext.registry import registry, Options from models import PlatejPlugin class PayOptions(Options): attributes = ('user_text',) parent = 'page' registry.register(PlatejPlugin, PayOptions)
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)
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)
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)
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)
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)
from dbgettext.registry import registry, Options from models import File class FileOptions(Options): attributes = ('title', ) parent = 'page' registry.register(File, FileOptions)
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)
from dbgettext.registry import registry, Options from models import Link class LinkOptions(Options): attributes = ('name', 'url', 'mailto') parent = 'page' registry.register(Link, LinkOptions)
from dbgettext.registry import registry, Options from models import Picture class PictureOptions(Options): attributes = ('url', 'alt') parent = 'page' registry.register(Picture, PictureOptions)