# Path: aldryn_gallery/models.py
# class GalleryPlugin(CMSPlugin):
#     STANDARD = 'standard'
# 
#     STYLE_CHOICES = [
#         (STANDARD, _('Standard')),
#     ]
# 
#     ENGINE_CHOICES = (
#         ('fade', _('Fade')),
#         ('slide', _('Slide'))
#     )
# 
#     cmsplugin_ptr = CMSPluginField()
#     style = models.CharField(
#         _('Style'), choices=STYLE_CHOICES + get_additional_styles(), default=STANDARD, max_length=50)
#     extra_styles = models.CharField(
#         _('Extra styles'), max_length=50, blank=True,
#         help_text=_('An arbitrary string of CSS classes to add'))
#     engine = models.CharField(_('Engine'), choices=ENGINE_CHOICES, default=ENGINE_CHOICES[0][0], max_length=50)
#     timeout = models.IntegerField(_('Timeout'), default=5000, help_text=_("Set to 0 to disable autoplay"))
#     duration = models.IntegerField(_('Duration'), default=300)
#     shuffle = models.BooleanField(_('Shuffle slides'), default=False)
# 
#     def __unicode__(self):
#         style = _('Style')
#         engine = _('Engine')
#         timeout = _('Timeout')
#         duration = _('Duration')
#         shuffle = _('Shuffle Slides')
#         return u'%s: %s, %s: %s, %s: %i, %s: %i, %s: %s' % (
#             style, self.style.title(), engine, self.engine.title(),
#             timeout, self.timeout, duration, self.duration, shuffle, self.shuffle
#         )


from django import forms
from django.template import TemplateDoesNotExist
from django.template.loader import select_template
from .models import GalleryPlugin
# -*- coding: utf-8 -*-



class GalleryPluginForm(forms.ModelForm):

    class Meta:
        fields = ['style', 'extra_styles', 'engine', 'timeout', 'duration', 'shuffle']
        model = GalleryPlugin

    def clean_style(self):
        style = self.cleaned_data.get('style')
        # Check if template for style exists:
        try:
            select_template(
                ['aldryn_gallery/plugins/{}/gallery.html'.format(style)])
        except TemplateDoesNotExist:
            raise forms.ValidationError(
                "Not a valid style (Template "

# Path: aldryn_gallery/models.py
# class GalleryPlugin(CMSPlugin):
#     STANDARD = 'standard'
# 
#     STYLE_CHOICES = [
#         (STANDARD, _('Standard')),
#     ]
# 
#     ENGINE_CHOICES = (
#         ('fade', _('Fade')),
#         ('slide', _('Slide'))
#     )
# 
#     cmsplugin_ptr = CMSPluginField()
#     style = models.CharField(
#         _('Style'), choices=STYLE_CHOICES + get_additional_styles(), default=STANDARD, max_length=50)
#     extra_styles = models.CharField(
#         _('Extra styles'), max_length=50, blank=True,
#         help_text=_('An arbitrary string of CSS classes to add'))
#     engine = models.CharField(_('Engine'), choices=ENGINE_CHOICES, default=ENGINE_CHOICES[0][0], max_length=50)
#     timeout = models.IntegerField(_('Timeout'), default=5000, help_text=_("Set to 0 to disable autoplay"))
#     duration = models.IntegerField(_('Duration'), default=300)
#     shuffle = models.BooleanField(_('Shuffle slides'), default=False)
# 
#     def __unicode__(self):
#         style = _('Style')
#         engine = _('Engine')
#         timeout = _('Timeout')
#         duration = _('Duration')
#         shuffle = _('Shuffle Slides')
#         return u'%s: %s, %s: %s, %s: %i, %s: %i, %s: %s' % (
#             style, self.style.title(), engine, self.engine.title(),
#             timeout, self.timeout, duration, self.duration, shuffle, self.shuffle
#         )


# Path: aldryn_gallery/forms.py
from django import forms
from django.template import TemplateDoesNotExist
from django.template.loader import select_template
from .models import GalleryPlugin

# -*- coding: utf-8 -*-



class GalleryPluginForm(forms.ModelForm):

    class Meta:
        fields = ['style', 'extra_styles', 'engine', 'timeout', 'duration', 'shuffle']
        model = GalleryPlugin

    def clean_style(self):
        style = self.cleaned_data.get('style')
        # Check if template for style exists:
        try:
            select_template(
                ['aldryn_gallery/plugins/{}/gallery.html'.format(style)])
        except TemplateDoesNotExist:
            raise forms.ValidationError(
                "Not a valid style (Template "

                "'aldryn_gallery/plugins/{}/gallery.html' "