From 54b2684178c16b188aca07f1af0b963e7faf75c3 Mon Sep 17 00:00:00 2001 From: gfawcett Date: Mon, 16 Aug 2010 22:56:30 +0000 Subject: [PATCH] handle term-sequencing error in form validation, not just in the model. git-svn-id: svn://svn.open-ils.org/ILS-Contrib/servres/trunk@960 6d9bc8c9-1ec2-4278-b937-99fde70a366f --- conifer/syrup/views/sites.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/conifer/syrup/views/sites.py b/conifer/syrup/views/sites.py index 072db11..b06c20c 100644 --- a/conifer/syrup/views/sites.py +++ b/conifer/syrup/views/sites.py @@ -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)' % ( -- 2.11.0