コード例 #1
0
 def __init__(self, pattern, display_names=None, *args, **kwargs):
     if 'coerce' in kwargs:
         raise TypeError("`coerce` should not be set directly")
     kwargs['coerce'] = force_text
     self._pattern = pattern
     self._display_names = display_names
     # twiddle over the choices.
     if 'choices' in kwargs:
         templates = kwargs.pop('choices')
         if callable(templates):
             templates = templates()
     else:
        templates = find_all_templates(pattern=pattern)
     choices = list(template_choices(templates=templates,
                                     display_names=self._display_names))
     kwargs.update(choices=choices)
     super(TemplateChoiceField, self).__init__(*args, **kwargs)
     if not self.required or len(choices) == 0:
         self.choices = BLANK_CHOICE_DASH + choices
コード例 #2
0
ファイル: utils.py プロジェクト: kezabelle/django-editregions
def get_markdown_files():
    return find_all_templates(pattern='*.md')
コード例 #3
0
 def get_matches(self):
     if self.evaluated is None:
         self.evaluated = find_all_templates(pattern=self.pattern)
     return self.evaluated
コード例 #4
0
import threading
from django.core.exceptions import ValidationError

from cms.models import CMSPlugin, Page
from django.db import models
from django.utils.translation import ugettext_lazy as _, get_language
from inline_ordering.models import Orderable
import templatefinder

localdata = threading.local()
localdata.TEMPLATE_CHOICES = templatefinder.find_all_templates('cmsplugin_s3slider/*.html')
TEMPLATE_CHOICES = localdata.TEMPLATE_CHOICES

class GalleryPlugin(CMSPlugin):

    template = models.CharField(
        max_length=255,
        choices=TEMPLATE_CHOICES,
        default='cmsplugin_s3slider/gallery.html',
        editable=len(TEMPLATE_CHOICES) > 1)

    timeout = models.IntegerField(default=3000)

    POSITIONS = (
        ('left', _('Left')),
        ('right', _('Right')),
        ('center', _('Center')),
        )
    alignment = models.CharField(max_length=8,
                                 choices=POSITIONS,
                                 default='left')