handle term-sequencing error in form validation, not just in the model.
authorgfawcett <gfawcett@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Mon, 16 Aug 2010 22:56:30 +0000 (22:56 +0000)
committergfawcett <gfawcett@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Mon, 16 Aug 2010 22:56:30 +0000 (22:56 +0000)
git-svn-id: svn://svn.open-ils.org/ILS-Contrib/servres/trunk@960 6d9bc8c9-1ec2-4278-b937-99fde70a366f

conifer/syrup/views/sites.py

index 072db11..b06c20c 100644 (file)
@@ -9,6 +9,13 @@ class NewSiteForm(ModelForm):
         model = models.Site
         exclude = ('access',)
 
+    def clean_end_term(self):
+        cd = self.cleaned_data
+        if cd['start_term'].start > cd['end_term'].start:
+            raise ValidationError(
+                'The end-term precedes the start-term.')
+        return cd['end_term']
+
     def __init__(self, *args, **kwargs):
         owner = self.base_fields['owner']
         owner.label_from_instance = lambda u: '%s (%s)' % (