Skip to content
This repository has been archived by the owner on Jan 11, 2019. It is now read-only.

Commit

Permalink
Merge 166d06c into 0e52cf3
Browse files Browse the repository at this point in the history
  • Loading branch information
yakky committed Mar 9, 2015
2 parents 0e52cf3 + 166d06c commit b5101e1
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion aldryn_gallery/forms.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from django.conf import settings
from django import forms
from django.template import TemplateDoesNotExist
from django.template.loader import select_template
Expand All @@ -12,11 +13,19 @@ class Meta:
fields = ['style', 'engine', 'timeout', 'duration', 'shuffle']
model = GalleryPlugin

def get_slide_template(self, style, name='slide'):
return 'aldryn_gallery/plugins/{}/{}.html'.format(
style, name,
)

def clean_style(self):
style = self.cleaned_data.get('style')
# Check if template for style exists:
try:
select_template(['aldryn_gallery/%s/gallery.html' % style])
if settings.ALDRYN_BOILERPLATE_NAME == 'legacy':
select_template([self.get_slide_template(style=style, name='slide')])
else: # for 'bootstrap3' boilerplate and the recommended structure for other boilerplates
select_template([self.get_slide_template(style=style, name='image_slide')])
except TemplateDoesNotExist:
raise forms.ValidationError("Not a valid style (Template does not exist)")
return style

0 comments on commit b5101e1

Please sign in to comment.