avoid overwriting of filename information in file fields when no file is uploaded
This commit is contained in:
parent
2c09a682db
commit
8cbe50a90b
2 changed files with 18 additions and 5 deletions
|
@ -148,8 +148,23 @@ class RecordsFieldInstance(GridFieldInstance):
|
|||
if not value:
|
||||
value = []
|
||||
result = []
|
||||
oldValue = getattr(self.clientContext, self.name, [])
|
||||
for idx, row in enumerate(value):
|
||||
item = self.unmarshallRow(row, idx)
|
||||
if item:
|
||||
if len(oldValue) > idx:
|
||||
oldItem = oldValue[idx]
|
||||
for k, v in item.items():
|
||||
if v != '__no_change__':
|
||||
oldItem[k] = v
|
||||
#if oldItem.get(k) == '__no_change__':
|
||||
# del oldItem[k]
|
||||
#if oldItem:
|
||||
result.append(oldItem)
|
||||
else:
|
||||
for k, v in item.items():
|
||||
if v == '__no_change__':
|
||||
del item[k]
|
||||
if item:
|
||||
result.append(item)
|
||||
return result
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (c) 2007 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
|
||||
|
@ -18,8 +18,6 @@
|
|||
|
||||
"""
|
||||
Instance adapter classes for schemas.
|
||||
|
||||
$Id$
|
||||
"""
|
||||
|
||||
from BTrees.OOBTree import OOBTree
|
||||
|
@ -110,7 +108,7 @@ class Editor(BaseInstance):
|
|||
fieldHandlers[ftype](context, value, fi, formState)
|
||||
else:
|
||||
oldValue = getattr(context, name, None)
|
||||
if value != oldValue:
|
||||
if value not in ('__no_change__', oldValue):
|
||||
setattr(context, name, value)
|
||||
fi.change = (oldValue, value)
|
||||
formState.changed = True
|
||||
|
|
Loading…
Add table
Reference in a new issue