text_ng = models.ForeignKey(TextNG, related_name='+') label = models.CharField(_('label'), max_length=20, validators=[ RegexValidator( regex='[_a-z]+', message=_('Only lower case characters.')) ]) def __unicode__(self): return self.label class Meta: abstract = True unique_together = ('text_ng', 'label') class TextNGVariableText(TextNGVariableBase): value = models.TextField(_('value'), null=True, blank=True) def __unicode__(self): return self.label + (' (%s)' % self.value if self.value else '') class Meta: verbose_name = _('text') verbose_name_plural = _('texts') if StrictVersion(django.get_version()) < StrictVersion('1.7'): register_type('text', TextNGVariableText)
class Meta: verbose_name = _('text') verbose_name_plural = _('texts') class TextNGVariableBase(models.Model): select_related = [] text_ng = models.ForeignKey(TextNG, related_name='+') label = models.CharField(_('label'), max_length=20, validators=[RegexValidator(regex='[_a-z]+', message=_('Only lower case characters.'))]) def __unicode__(self): return self.label class Meta: abstract = True unique_together = ('text_ng', 'label') class TextNGVariableText(TextNGVariableBase): value = models.TextField(_('value'), null=True, blank=True) def __unicode__(self): return self.label + (' (%s)' % self.value if self.value else '') class Meta: verbose_name = _('text') verbose_name_plural = _('texts') register_type('text', TextNGVariableText)
def ready(self): from cmsplugin_text_ng.models import TextNGVariableText register_type('text', TextNGVariableText)
# -*- coding: utf-8 -*- from django.utils.translation import ugettext_lazy as _ from filer.fields.image import FilerImageField from cmsplugin_text_ng.models import TextNGVariableBase from cmsplugin_text_ng.type_registry import register_type class TextNGVariableFilerImage(TextNGVariableBase): value = FilerImageField(null=True, blank=True, verbose_name=_('value')) class Meta: verbose_name = _('image') verbose_name_plural = _('images') register_type('image', TextNGVariableFilerImage)