Fixes in corefields
This commit is contained in:
parent
fbb2e1012c
commit
8e05927a32
7 changed files with 21 additions and 8 deletions
|
|
@ -9,7 +9,11 @@ import re
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from importlib import import_module
|
from importlib import import_module
|
||||||
from paramecio2.libraries.i18n import I18n
|
from paramecio2.libraries.i18n import I18n
|
||||||
from settings import config
|
try:
|
||||||
|
from settings import config
|
||||||
|
except:
|
||||||
|
print('You need a settings directory with a paramecio2 configuration')
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
pattern=re.compile('^\w+\.(py|html|phtml|js)$')
|
pattern=re.compile('^\w+\.(py|html|phtml|js)$')
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
from paramecio2.libraries.db.webmodel import PhangoField
|
from paramecio2.libraries.db.webmodel import PhangoField
|
||||||
from paramecio2.libraries.db import coreforms
|
from paramecio2.libraries.db import coreforms
|
||||||
from paramecio2.libraries.i18n import I18n
|
from paramecio2.libraries.i18n import I18n
|
||||||
|
from bs4 import BeautifulSoup
|
||||||
|
|
||||||
class IntegerField(PhangoField):
|
class IntegerField(PhangoField):
|
||||||
|
|
||||||
|
|
@ -157,10 +158,17 @@ class HTMLField(TextField):
|
||||||
|
|
||||||
def __init__(self, name, required=False):
|
def __init__(self, name, required=False):
|
||||||
super().__init__(name, required)
|
super().__init__(name, required)
|
||||||
|
self.trusted_tags=[]
|
||||||
|
|
||||||
def check(self, value):
|
def check(self, value):
|
||||||
|
|
||||||
return re.sub('<.*?script?>', '', value)
|
soup=BeautifulSoup(value, features='html.parser')
|
||||||
|
|
||||||
|
for tag in soup.findAll(True):
|
||||||
|
if tag.name not in self.trusted_tags:
|
||||||
|
tag.hidden=True
|
||||||
|
|
||||||
|
return soup.renderContents().decode('utf-8')
|
||||||
|
|
||||||
|
|
||||||
class ForeignKeyField(IntegerField):
|
class ForeignKeyField(IntegerField):
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ class DateField(PhangoField):
|
||||||
|
|
||||||
value=datetime.local_to_gmt(value)
|
value=datetime.local_to_gmt(value)
|
||||||
|
|
||||||
elif not datetime.obtain_timestamp(value, False):
|
elif not datetime.obtain_timestamp(value):
|
||||||
|
|
||||||
self.error=True
|
self.error=True
|
||||||
self.txt_error=self.error_default
|
self.txt_error=self.error_default
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ class DateTimeField(PhangoField):
|
||||||
|
|
||||||
value=datetime.local_to_gmt(value)
|
value=datetime.local_to_gmt(value)
|
||||||
|
|
||||||
elif not datetime.obtain_timestamp(value, False):
|
elif not datetime.obtain_timestamp(value):
|
||||||
|
|
||||||
self.error=True
|
self.error=True
|
||||||
self.txt_error=self.error_default
|
self.txt_error=self.error_default
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
from paramecio2.libraries.db.webmodel import WebModel, PhangoField
|
from paramecio2.libraries.db.webmodel import WebModel, PhangoField
|
||||||
|
import sys
|
||||||
try:
|
try:
|
||||||
|
|
||||||
import ujson as json
|
import ujson as json
|
||||||
|
|
@ -77,7 +78,7 @@ class JsonValueField(PhangoField):
|
||||||
|
|
||||||
except json.JSONDecodeError:
|
except json.JSONDecodeError:
|
||||||
|
|
||||||
value={}
|
final_value={}
|
||||||
self.error=True
|
self.error=True
|
||||||
self.txt_error=self.error_default
|
self.txt_error=self.error_default
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -478,8 +478,8 @@ class WebModel:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
except:
|
except:
|
||||||
self.query_error='Cannot insert the new row'
|
self.query_error='Cannot insert the new row '+sys.exc_info()[0]
|
||||||
print(sys.exc_info()[0])
|
#print(sys.exc_info()[0])
|
||||||
return False
|
return False
|
||||||
|
|
||||||
c=len(values)
|
c=len(values)
|
||||||
|
|
|
||||||
2
setup.py
2
setup.py
|
|
@ -21,7 +21,7 @@ setup(name='paramecio2',
|
||||||
url='https://bitbucket.org/paramecio/paramecio2fm/',
|
url='https://bitbucket.org/paramecio/paramecio2fm/',
|
||||||
packages=['paramecio2'],
|
packages=['paramecio2'],
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
install_requires=['flask', 'pymysql', 'sqlalchemy', 'colorama', 'python-slugify', 'mako', 'pillow', 'arrow'],
|
install_requires=['flask', 'pymysql', 'sqlalchemy', 'colorama', 'python-slugify', 'mako', 'pillow', 'arrow', 'beautifulsoup4'],
|
||||||
entry_points={'console_scripts': [
|
entry_points={'console_scripts': [
|
||||||
'paramecio2 = paramecio2.console:start', 'paramecio2db = paramecio2.libraries.db.dbadmin:start', 'paramecio2lang = paramecio2.libraries.check_i18n:start',
|
'paramecio2 = paramecio2.console:start', 'paramecio2db = paramecio2.libraries.db.dbadmin:start', 'paramecio2lang = paramecio2.libraries.check_i18n:start',
|
||||||
]},
|
]},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue