Fixes in imagefield and jsonfield

This commit is contained in:
absurdo 2023-09-13 00:17:46 +02:00
parent a741e51a76
commit bc05d7725e
3 changed files with 43 additions and 36 deletions

View file

@ -72,44 +72,50 @@ class ImageField(CharField):
#if not change
if not field_file in files_uploaded:
if field_file in files_uploaded:
if value=='':
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
if self.model.updated:
self.model.yes_reset_conditions=False
old_reset=self.model.yes_reset_conditions
with self.model.select([self.name]) as cur:
self.model.yes_reset_conditions=False
for arr_image in cur:
with self.model.select([self.name]) as cur:
if arr_image[self.name]!='':
try:
os.remove(arr_image[self.name])
except:
pass
for arr_image in cur:
#if arr_image[self.name]!=save_file and arr_image[self.name]!='':
if arr_image[self.name]!='':
try:
os.remove(arr_image[self.name])
except:
pass
#value=arr_image[self.name]
#if arr_image[self.name]!=save_file and arr_image[self.name]!='':
self.model.yes_reset_conditions=old_reset
self.txt_error='Field is empty'
self.error=True
#value=arr_image[self.name]
return ''
self.model.yes_reset_conditions=old_reset
self.txt_error='Field is empty'
self.error=True
else:
return ''
value=os.path.basename(value)
else:
return self.save_folder+'/'+value
value=os.path.basename(value)
return self.save_folder+'/'+value
else:
value=os.path.basename(value)
return self.save_folder+'/'+value
# Load image file

View file

@ -72,6 +72,7 @@ class JsonValueField(PhangoField):
super().__init__(name, required)
self.error_default='Sorry, the json dict is invalid'
self.default_value={}
#self.set_default='NOT NULL'
@ -86,7 +87,7 @@ class JsonValueField(PhangoField):
except json.JSONDecodeError:
final_value={}
final_value='{}'
self.error=True
self.txt_error=self.error_default

View file

@ -5,7 +5,7 @@ import os
from setuptools import setup, find_packages
if sys.version_info < (3, 6):
if sys.version_info < (3, 8):
raise NotImplementedError("Sorry, you need at least Python 3.6 for use paramecio2.")
#import paramecio
@ -13,7 +13,7 @@ if sys.version_info < (3, 6):
# If you install passlib and bcrypt, the password system will use bcrypt by default, if not, will use native crypt libc
setup(name='paramecio2',
version='2.0.21',
version='2.0.22',
description='Simple Web Framework based in flask and Mako.',
long_description='This framework is a simple framework used for create web apps. Paramecio is modular and fast. By default have a module called admin that can be used for create admin sites',
author='Antonio de la Rosa Caballero',