From 4f54192ae47a95898d00c614d42a9fdbf3ec8f6e Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Mon, 7 Oct 2013 14:39:19 +0200 Subject: [PATCH] allow for skipping certain fields when checking for empty rows --- composer/schema/grid/field.py | 6 +++++- composer/schema/grid/interfaces.py | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/composer/schema/grid/field.py b/composer/schema/grid/field.py index 78f57a2..3630f82 100644 --- a/composer/schema/grid/field.py +++ b/composer/schema/grid/field.py @@ -127,7 +127,11 @@ class GridFieldInstance(ListFieldInstance): continue if value: item[fi.name] = value - return item + ignoreInCheckOnEmpty = getattr(self.context, 'ignoreInCheckOnEmpty', []) + for k, v in item.items(): + if k not in ignoreInCheckOnEmpty and v != '__no_change__': + return item + return {} class RecordsFieldInstance(GridFieldInstance): diff --git a/composer/schema/grid/interfaces.py b/composer/schema/grid/interfaces.py index 1979be0..bc521d9 100644 --- a/composer/schema/grid/interfaces.py +++ b/composer/schema/grid/interfaces.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2011 Helmut Merz helmutm@cy55.de +# Copyright (c) 2013 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 @@ -38,6 +38,7 @@ class Grid(schema.List): instanceName='grid')) column_types = [] + ignoreInCheckOnEmpty = [] cardinality = None