Fixes
This commit is contained in:
parent
bef630ec1d
commit
f5adbc376a
6 changed files with 39 additions and 54 deletions
|
|
@ -76,8 +76,12 @@ class GenerateAdminClass:
|
|||
post=self.model.select_a_row(getpostfiles.get['id'], [], True)
|
||||
title_edit=I18n.lang('common', 'edit_new_item', 'Edit item')
|
||||
|
||||
if post==None:
|
||||
post={}
|
||||
if post==None or post==False:
|
||||
|
||||
if getpostfiles.get['id']=='0':
|
||||
post={}
|
||||
else:
|
||||
return ""
|
||||
|
||||
form=show_form(post, edit_forms, self.t, False)
|
||||
|
||||
|
|
|
|||
|
|
@ -22,33 +22,37 @@ class GetPostFiles:
|
|||
|
||||
self.get=request.query.decode()
|
||||
|
||||
def obtain_post(self, required_post=[]):
|
||||
def obtain_post(self, required_post=[], ignore_csrf_token=False):
|
||||
|
||||
self.post={}
|
||||
|
||||
self.post=request.forms.decode()
|
||||
|
||||
if len(required_post)==0:
|
||||
required_post=self.post.keys()
|
||||
|
||||
for post in required_post:
|
||||
|
||||
self.post[post]=self.post.get(post, '')
|
||||
|
||||
s=get_session()
|
||||
|
||||
if 'csrf_token' in s:
|
||||
|
||||
self.post['csrf_token']=self.post.get('csrf_token', '')
|
||||
|
||||
if self.post['csrf_token']!=s['csrf_token'] and self.post['csrf_token'].strip()!="":
|
||||
if ignore_csrf_token==False:
|
||||
|
||||
if 'csrf_token' in s:
|
||||
|
||||
raise NameError('Error: you need a valid csrf_token')
|
||||
else:
|
||||
#Clean csrf_token
|
||||
|
||||
del s['csrf_token']
|
||||
self.post['csrf_token']=self.post.get('csrf_token', '')
|
||||
|
||||
if self.post['csrf_token']!=s['csrf_token'] and self.post['csrf_token'].strip()!="":
|
||||
|
||||
raise NameError('Error: you need a valid csrf_token')
|
||||
else:
|
||||
#Clean csrf_token
|
||||
|
||||
del s['csrf_token']
|
||||
|
||||
|
||||
else:
|
||||
raise NameError('Error: you don\'t send any valid csrf_token')
|
||||
else:
|
||||
raise NameError('Error: you don\'t send any valid csrf_token')
|
||||
|
||||
#Check post_token
|
||||
|
||||
|
|
|
|||
|
|
@ -287,7 +287,13 @@ class HeaderHTML:
|
|||
|
||||
self.css_local[module]=self.css_local.get(module, [])
|
||||
|
||||
self.css_local[module].append(css)
|
||||
try:
|
||||
|
||||
self.css_local[module].index(css)
|
||||
|
||||
except:
|
||||
|
||||
self.css_local[module].append(css)
|
||||
|
||||
return ''
|
||||
|
||||
|
|
@ -297,7 +303,11 @@ class HeaderHTML:
|
|||
|
||||
self.js_local[module]=self.js_local.get(module, [])
|
||||
|
||||
self.js_local[module].append(js)
|
||||
try:
|
||||
self.js_local[module].index(js)
|
||||
|
||||
except:
|
||||
self.js_local[module].append(js)
|
||||
|
||||
return ''
|
||||
|
||||
|
|
|
|||
|
|
@ -206,7 +206,7 @@ class WebModel:
|
|||
|
||||
sql="insert into `"+self.name+"` (`"+"`, `".join(fields)+"`) VALUES ("+", ".join(arr_str)+")"
|
||||
|
||||
cursor=self.sqlclass.query(sql, values+self.conditions[1], self.connection_id)
|
||||
cursor=self.sqlclass.query(sql, values, self.connection_id)
|
||||
|
||||
if cursor.rowcount>0:
|
||||
|
||||
|
|
|
|||
|
|
@ -74,39 +74,6 @@ for module in config.modules:
|
|||
|
||||
#add_func_static_module(controller_base)
|
||||
|
||||
|
||||
"""
|
||||
try:
|
||||
|
||||
controller_path=load(module)
|
||||
|
||||
controller_base=os.path.dirname(controller_path.__file__)
|
||||
|
||||
base_module=module.split('.')[-1]
|
||||
|
||||
arr_module_path[base_module]=controller_base
|
||||
|
||||
dir_controllers=os.listdir(controller_base)
|
||||
|
||||
for controller in dir_controllers:
|
||||
|
||||
if controller.find('.py')!=-1 and controller.find('__init__')==-1:
|
||||
|
||||
controller_py=controller.replace('.py', '')
|
||||
|
||||
load(module+'.'+controller_py)
|
||||
|
||||
add_func_static_module(controller_base)
|
||||
|
||||
except:
|
||||
|
||||
print("Exception in user code:")
|
||||
print("-"*60)
|
||||
traceback.print_exc(file=sys.stdout)
|
||||
print("-"*60)
|
||||
"""
|
||||
#exit()
|
||||
|
||||
#Prepare ssl
|
||||
|
||||
if config.ssl==True:
|
||||
|
|
|
|||
|
|
@ -34,9 +34,9 @@ module_admin=path.dirname(__file__)
|
|||
|
||||
env=env_theme(__file__)
|
||||
|
||||
def make_admin_url(url):
|
||||
def make_admin_url(url, query_args={}):
|
||||
|
||||
return make_url('%s/%s' % (config.admin_folder, url))
|
||||
return make_url('%s/%s' % (config.admin_folder, url), query_args)
|
||||
|
||||
@get('/'+config.admin_folder)
|
||||
@get('/'+config.admin_folder+'/<module>')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue