Fixes in imagefield and jsonfield
This commit is contained in:
parent
a741e51a76
commit
bc05d7725e
3 changed files with 43 additions and 36 deletions
|
|
@ -72,44 +72,50 @@ class ImageField(CharField):
|
|||
|
||||
#if not change
|
||||
|
||||
if not field_file in files_uploaded:
|
||||
|
||||
if value=='':
|
||||
if field_file in files_uploaded:
|
||||
|
||||
if files_uploaded[field_file].filename=='':
|
||||
|
||||
if self.model:
|
||||
if value=='':
|
||||
|
||||
if self.model.updated:
|
||||
if self.model:
|
||||
|
||||
old_reset=self.model.yes_reset_conditions
|
||||
|
||||
self.model.yes_reset_conditions=False
|
||||
|
||||
with self.model.select([self.name]) as cur:
|
||||
|
||||
for arr_image in cur:
|
||||
|
||||
if arr_image[self.name]!='':
|
||||
try:
|
||||
os.remove(arr_image[self.name])
|
||||
except:
|
||||
pass
|
||||
|
||||
#if arr_image[self.name]!=save_file and arr_image[self.name]!='':
|
||||
|
||||
#value=arr_image[self.name]
|
||||
|
||||
self.model.yes_reset_conditions=old_reset
|
||||
self.txt_error='Field is empty'
|
||||
self.error=True
|
||||
|
||||
return ''
|
||||
if self.model.updated:
|
||||
|
||||
old_reset=self.model.yes_reset_conditions
|
||||
|
||||
self.model.yes_reset_conditions=False
|
||||
|
||||
with self.model.select([self.name]) as cur:
|
||||
|
||||
for arr_image in cur:
|
||||
|
||||
if arr_image[self.name]!='':
|
||||
try:
|
||||
os.remove(arr_image[self.name])
|
||||
except:
|
||||
pass
|
||||
|
||||
#if arr_image[self.name]!=save_file and arr_image[self.name]!='':
|
||||
|
||||
#value=arr_image[self.name]
|
||||
|
||||
self.model.yes_reset_conditions=old_reset
|
||||
self.txt_error='Field is empty'
|
||||
self.error=True
|
||||
|
||||
return ''
|
||||
|
||||
else:
|
||||
|
||||
value=os.path.basename(value)
|
||||
|
||||
return self.save_folder+'/'+value
|
||||
else:
|
||||
|
||||
value=os.path.basename(value)
|
||||
|
||||
return self.save_folder+'/'+value
|
||||
else:
|
||||
|
||||
value=os.path.basename(value)
|
||||
|
||||
return self.save_folder+'/'+value
|
||||
|
||||
# Load image file
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue