From 9345efa7a69d1daacc1568c814f9e7ebdac2410b Mon Sep 17 00:00:00 2001 From: helmutm Date: Thu, 31 Mar 2011 11:55:09 +0000 Subject: [PATCH] provide a default comparison value that is used for querying if no comparison value has been entered for a field git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@4210 fd906abe-77d9-0310-91a1-e0d9ade77398 --- composer/report/base.py | 15 ++++++++------- composer/report/field.py | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/composer/report/base.py b/composer/report/base.py index 2587f19..9965d7b 100644 --- a/composer/report/base.py +++ b/composer/report/base.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2010 Helmut Merz helmutm@cy55.de +# Copyright (c) 2011 Helmut Merz helmutm@cy55.de # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -152,9 +152,11 @@ class LeafQueryCriteria(BaseQueryCriteria, Element): self.field = field def check(self, row): - #if not self.comparisonValue: - if self.comparisonValue in (None, '',): - return True + comparisonValue = self.comparisonValue + if comparisonValue in (None, '',): + comparisonValue = self.field.defaultComparisonValue + if comparisonValue in (None, '',): + return True value = self.field.getSelectValue(row) op = operators.get(self.operator) if op is None: @@ -162,11 +164,10 @@ class LeafQueryCriteria(BaseQueryCriteria, Element): if op is None: # TODO: log warning return True - #print '***', self.field.name, repr(value), op, repr(self.comparisonValue) - return op(value, self.comparisonValue) + return op(value, comparisonValue) def showComparisonValue(self): - if self.field.fieldType == 'selection': + if self.field.fieldType == 'selection' and self.comparisonValue: return ', '.join([v for v in self.comparisonValue]) return self.comparisonValue diff --git a/composer/report/field.py b/composer/report/field.py index 2eda7a8..21f61b9 100644 --- a/composer/report/field.py +++ b/composer/report/field.py @@ -41,7 +41,7 @@ class Field(Component): fieldType = 'text' vocabulary = None - default = None + default = defaultComparisonValue = None instance_name = None storeData = True renderer = 'standard'