summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErnesto Rico-Schmidt <e.rico.schmidt@gmail.com>2013-03-08 22:14:19 (GMT)
committerErnesto Rico-Schmidt <e.rico.schmidt@gmail.com>2013-03-08 22:14:19 (GMT)
commit0d43cf483767e98d62689bff5a654cdee9818b0a (patch)
tree6dc2b56f7f5e5a7cccf9789c7ff8dfe102883547
parent4ccc96c61f3b911d16454076c875dda6f929f0b0 (diff)
added forms.py
-rw-r--r--program/forms.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/program/forms.py b/program/forms.py
new file mode 100644
index 0000000..0ecd371
--- /dev/null
+++ b/program/forms.py
@@ -0,0 +1,42 @@
+from django import forms
+from django.core.files.images import get_image_dimensions
+
+from program.models import MusicFocus, ShowInformation, ShowTopic
+
+class FormWithButton(forms.ModelForm):
+ def clean_button(self):
+ button = self.cleaned_data.get('button')
+ if button:
+ width, height = get_image_dimensions(button)
+ if width != 11 or height != 11:
+ raise forms.ValidationError("width or height is not 11, (11x11)")
+ return button
+
+ def clean_button_hover(self):
+ button_hover = self.cleaned_data.get('button_hover')
+ if button_hover:
+ width, height = get_image_dimensions(button_hover)
+ if width != 11 or height != 11:
+ raise forms.ValidationError("width or height is not 11, (11x11)")
+ return button_hover
+
+ def clean_big_button(self):
+ big_button = self.cleaned_data.get('big_button')
+ if big_button:
+ width, height = get_image_dimensions(big_button)
+ if width != 17 or height != 17:
+ raise forms.ValidationError("width or height is not 17, (17x17)")
+ return big_button
+
+class MusicFocusForm(FormWithButton):
+ class Meta:
+ model = MusicFocus
+
+class ShowInformationForm(FormWithButton):
+ class Meta:
+ model = ShowInformation
+
+class ShowTopicForm(FormWithButton):
+ class Meta:
+ model = ShowTopic
+