From e92ff84e83b0d3f6bf632010b93ecd2f75cd676c Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Tue, 16 Jul 2013 12:51:42 +0200 Subject: Manage strange session error. --- archaeological_operations/forms.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'archaeological_operations/forms.py') diff --git a/archaeological_operations/forms.py b/archaeological_operations/forms.py index a801b60a6..c1003dfe9 100644 --- a/archaeological_operations/forms.py +++ b/archaeological_operations/forms.py @@ -277,9 +277,14 @@ class OperationFormGeneral(forms.Form): if ops.count(): max_val = models.Operation.objects.filter(year=year).aggregate( Max('operation_code'))["operation_code__max"] - raise forms.ValidationError(_(u"Operation code already exist for " + msg = '' + if year and max_val: + msg = _(u"Operation code already exist for " u"year: %(year)d - use a value bigger than %(last_val)d") % { - 'year':year, 'last_val':max_val}) + 'year':year, 'last_val':max_val} + else: + msg = _(u"Bad operation code") + raise forms.ValidationError(msg) return self.cleaned_data class OperationFormPreventive(forms.Form): -- cgit v1.2.3