Fixes in forms, added new plugins, etc
This commit is contained in:
parent
ecbd5ef806
commit
359cb22a93
10 changed files with 111 additions and 16 deletions
|
|
@ -98,7 +98,7 @@ def get_menu(modules_admin):
|
||||||
menu[mod[2]]=mod[0]
|
menu[mod[2]]=mod[0]
|
||||||
|
|
||||||
if len(mod)<4:
|
if len(mod)<4:
|
||||||
menu[mod[2]]='<i class="fa fa-arrow-down" aria-hidden="true"></i> '+menu[mod[2]]
|
menu[mod[2]]='<i class="fa fa-arrow-down" aria-hidden="true"></i>'+menu[mod[2]]
|
||||||
|
|
||||||
for submod in mod[1]:
|
for submod in mod[1]:
|
||||||
if submod[2] in menu:
|
if submod[2] in menu:
|
||||||
|
|
|
||||||
|
|
@ -63,19 +63,22 @@ class GetPostFiles:
|
||||||
|
|
||||||
self.files={}
|
self.files={}
|
||||||
|
|
||||||
def obtain_query(self):
|
def obtain_query(self, ignore_csrf_token=True):
|
||||||
|
|
||||||
self.query={}
|
self.query={}
|
||||||
|
|
||||||
self.query=request.query.decode()
|
self.query=request.query.decode()
|
||||||
|
|
||||||
|
if ignore_csrf_token==False and no_csrf==False:
|
||||||
|
check_csrf(self.query)
|
||||||
|
|
||||||
# Deprecated, is confuse.
|
# Deprecated, is confuse.
|
||||||
|
|
||||||
def obtain_get(self):
|
def obtain_get(self, ignore_csrf_token=True):
|
||||||
|
|
||||||
self.get={}
|
self.obtain_query(ignore_csrf_token)
|
||||||
|
|
||||||
self.get=request.query.decode()
|
self.get=self.query
|
||||||
|
|
||||||
def obtain_post(self, required_post=[], ignore_csrf_token=False):
|
def obtain_post(self, required_post=[], ignore_csrf_token=False):
|
||||||
|
|
||||||
|
|
@ -131,3 +134,28 @@ class GetPostFiles:
|
||||||
def request_method():
|
def request_method():
|
||||||
|
|
||||||
return request.method
|
return request.method
|
||||||
|
|
||||||
|
def check_csrf(post):
|
||||||
|
|
||||||
|
s=get_session()
|
||||||
|
|
||||||
|
if 'csrf_token' in s:
|
||||||
|
|
||||||
|
post['csrf_token']=post.get('csrf_token', '')
|
||||||
|
|
||||||
|
if post['csrf_token']!=s['csrf_token'] or post['csrf_token'].strip()=="":
|
||||||
|
|
||||||
|
#raise NameError('Error: you need a valid csrf_token')
|
||||||
|
raise HTTPResponse(body=json.dumps({'error_csrf': 1, 'error': 1, 'token_invalid': 1}), status=200, headers={'Content-type': 'application/json'})
|
||||||
|
else:
|
||||||
|
#Clean csrf_token
|
||||||
|
|
||||||
|
if change_csrf:
|
||||||
|
|
||||||
|
del s['csrf_token']
|
||||||
|
|
||||||
|
s.save()
|
||||||
|
|
||||||
|
else:
|
||||||
|
#raise NameError('Error: you don\'t send any valid csrf_token')
|
||||||
|
raise HTTPResponse(body=json.dumps({'error_csrf': 1, 'error': 1, 'token_invalid': 0}), status=200, headers={'Content-type': 'application/json'})
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ from paramecio.citoplasma.i18n import I18n
|
||||||
from paramecio.citoplasma.httputils import GetPostFiles
|
from paramecio.citoplasma.httputils import GetPostFiles
|
||||||
from bottle import request
|
from bottle import request
|
||||||
import sys
|
import sys
|
||||||
|
import re
|
||||||
|
|
||||||
class SimpleList:
|
class SimpleList:
|
||||||
|
|
||||||
|
|
@ -78,6 +79,8 @@ class SimpleList:
|
||||||
|
|
||||||
self.jln='<br />'
|
self.jln='<br />'
|
||||||
|
|
||||||
|
self.ajax=False
|
||||||
|
|
||||||
def restore_fields(self):
|
def restore_fields(self):
|
||||||
self.fields=self.model.fields.keys()
|
self.fields=self.model.fields.keys()
|
||||||
|
|
||||||
|
|
@ -191,15 +194,41 @@ class SimpleList:
|
||||||
|
|
||||||
#print(self.model.fields.keys())
|
#print(self.model.fields.keys())
|
||||||
|
|
||||||
|
func_jscript=''
|
||||||
|
|
||||||
|
if self.ajax==True:
|
||||||
|
func_jscript='get_page()'
|
||||||
|
|
||||||
pages=Pages.show( begin_page, total_elements, num_elements, link ,initial_num_pages=self.initial_num_pages, variable='begin_page', label='', func_jscript='')
|
pages=Pages.show( begin_page, total_elements, num_elements, link ,initial_num_pages=self.initial_num_pages, variable='begin_page', label='', func_jscript='')
|
||||||
|
|
||||||
self.begin_page=str(self.begin_page)
|
self.begin_page=str(self.begin_page)
|
||||||
|
|
||||||
self.model.yes_reset_conditions=True
|
self.model.yes_reset_conditions=True
|
||||||
|
|
||||||
listing=self.t.render_template('utils/list.phtml', simplelist=self, list=list_items, pages=pages)
|
listing=self.t.render_template('utils/list.phtml', simplelist=self, list=list_items, pages=pages, ajax=self.ajax)
|
||||||
|
|
||||||
list_items.close()
|
list_items.close()
|
||||||
|
|
||||||
return listing
|
return listing
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_ajax_page(model):
|
||||||
|
|
||||||
|
p=GetPostFiles()
|
||||||
|
|
||||||
|
p.obtain_query()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class AjaxList(SimpleList):
|
||||||
|
|
||||||
|
def __init__(self, model, url, ajax_url, t):
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ class Pages:
|
||||||
if initial_page>0:
|
if initial_page>0:
|
||||||
initial_link=add_get_parameters(link, **{variable: '0'});
|
initial_link=add_get_parameters(link, **{variable: '0'});
|
||||||
middle_link=add_get_parameters(link, **{variable: str((initial_page-num_elements)) } );
|
middle_link=add_get_parameters(link, **{variable: str((initial_page-num_elements)) } );
|
||||||
pages += "<a class=\""+Pages.css_class+"\" href=\""+initial_link+"\" onclick=\"func_jscript\">1</a> <a class=\""+Pages.css_class+"\" href=\""+middle_link+"\"><<</a> "
|
pages += "<a class=\""+Pages.css_class+"\" href=\""+initial_link+"\" onclick=\"${func_jscript}\">1</a> <a class=\""+Pages.css_class+"\" href=\""+middle_link+"\"><<</a> "
|
||||||
|
|
||||||
arr_pages={}
|
arr_pages={}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ class DbPlugin(object):
|
||||||
def setup(self, app):
|
def setup(self, app):
|
||||||
''' Make sure that other installed plugins don't affect the same keyword argument.'''
|
''' Make sure that other installed plugins don't affect the same keyword argument.'''
|
||||||
for other in app.plugins:
|
for other in app.plugins:
|
||||||
if not isinstance(other, LoginPlugin): continue
|
if not isinstance(other, DbPlugin): continue
|
||||||
if other.keyword == self.keyword:
|
if other.keyword == self.keyword:
|
||||||
raise PluginError("Found another login plugin with "\
|
raise PluginError("Found another login plugin with "\
|
||||||
"conflicting settings (non-unique keyword).")
|
"conflicting settings (non-unique keyword).")
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,14 @@
|
||||||
<td class="options_td">${ extra_field }</td>
|
<td class="options_td">${ extra_field }</td>
|
||||||
% endfor
|
% endfor
|
||||||
</tr>
|
</tr>
|
||||||
|
<%
|
||||||
|
pos=0
|
||||||
|
%>
|
||||||
% for row in list:
|
% for row in list:
|
||||||
|
<%
|
||||||
|
if not 'pos' in row:
|
||||||
|
row['pos']=pos
|
||||||
|
%>
|
||||||
<tr class="row_list">
|
<tr class="row_list">
|
||||||
% for field in simplelist.fields_showed:
|
% for field in simplelist.fields_showed:
|
||||||
% if simplelist.model.fields[field].escape==True:
|
% if simplelist.model.fields[field].escape==True:
|
||||||
|
|
@ -44,6 +51,9 @@
|
||||||
<td class="options_td">${ simplelist.set_options(extra_field_func, row)|n }</td>
|
<td class="options_td">${ simplelist.set_options(extra_field_func, row)|n }</td>
|
||||||
% endfor
|
% endfor
|
||||||
</tr>
|
</tr>
|
||||||
|
<%
|
||||||
|
pos+=1
|
||||||
|
%>
|
||||||
% endfor
|
% endfor
|
||||||
</table>
|
</table>
|
||||||
<p>
|
<p>
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,27 @@ class CheckForm():
|
||||||
|
|
||||||
return post, arr_form
|
return post, arr_form
|
||||||
|
|
||||||
|
def check_form(post, arr_form, sufix_form='_error'):
|
||||||
|
|
||||||
|
error=0
|
||||||
|
error_form={}
|
||||||
|
|
||||||
|
for k in arr_form.keys():
|
||||||
|
|
||||||
|
post[k]=post.get(k, '')
|
||||||
|
|
||||||
|
if arr_form[k].field==None:
|
||||||
|
arr_form[k].field=corefields.CharField(k, 255, required=False)
|
||||||
|
|
||||||
|
post[k]=arr_form[k].field.check(post[k])
|
||||||
|
arr_form[k].txt_error=arr_form[k].field.txt_error
|
||||||
|
|
||||||
|
if arr_form[k].field.error==True and arr_form[k].required==True:
|
||||||
|
error_form['#'+k+sufix_form]=arr_form[k].txt_error
|
||||||
|
error+=1
|
||||||
|
|
||||||
|
return error, error_form, post, arr_form
|
||||||
|
|
||||||
def show_form(post, arr_form, t, yes_error=True, pass_values=True, modelform_tpl='forms/modelform.phtml'):
|
def show_form(post, arr_form, t, yes_error=True, pass_values=True, modelform_tpl='forms/modelform.phtml'):
|
||||||
|
|
||||||
# Create csrf_token in session
|
# Create csrf_token in session
|
||||||
|
|
|
||||||
|
|
@ -140,7 +140,7 @@ p {
|
||||||
/* border:solid #cccccc;
|
/* border:solid #cccccc;
|
||||||
border-width:0px 1px 1px 0px;*/
|
border-width:0px 1px 1px 0px;*/
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
padding-bottom: 100px;
|
/* padding-bottom: 100px;*/
|
||||||
overflow:hidden;
|
overflow:hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -256,6 +256,13 @@ p {
|
||||||
overflow:auto;
|
overflow:auto;
|
||||||
border: solid #cbcbcb;
|
border: solid #cbcbcb;
|
||||||
border-width: 0px 0px 1px 0px;
|
border-width: 0px 0px 1px 0px;
|
||||||
|
min-height: 90vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content_admin i {
|
||||||
|
|
||||||
|
margin-right: 10px;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.contents
|
.contents
|
||||||
|
|
|
||||||
10
paramecio/modules/admin/media/js/jquery.min.js
vendored
10
paramecio/modules/admin/media/js/jquery.min.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -61,11 +61,11 @@ ${HeaderHTML.header_home()|n}
|
||||||
<div class="content_admin">
|
<div class="content_admin">
|
||||||
<nav id="menu" class="nav-collapse">
|
<nav id="menu" class="nav-collapse">
|
||||||
<ul>
|
<ul>
|
||||||
<li class="menu_title"><%block name="applications"><i class="fa fa-gear" aria-hidden="true"></i> ${lang('admin', 'applications', 'Applications')}</li></%block>
|
<li class="menu_title"><%block name="applications"><i class="fa fa-gear" aria-hidden="true"></i>${lang('admin', 'applications', 'Applications')}</li></%block>
|
||||||
% for module in menu:
|
% for module in menu:
|
||||||
% if type(menu[module]).__name__=='list':
|
% if type(menu[module]).__name__=='list':
|
||||||
% if menu[module][0]!="":
|
% if menu[module][0]!="":
|
||||||
<li><a href="${check_menu(module).strip()|n}">${menu[module][3]|n} ${menu[module][0]}</a></li>
|
<li><a href="${check_menu(module).strip()|n}">${menu[module][3]|n}${menu[module][0]}</a></li>
|
||||||
% endif
|
% endif
|
||||||
% else:
|
% else:
|
||||||
% if menu[module]!="":
|
% if menu[module]!="":
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue