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]
|
||||
|
||||
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]:
|
||||
if submod[2] in menu:
|
||||
|
|
|
|||
|
|
@ -63,19 +63,22 @@ class GetPostFiles:
|
|||
|
||||
self.files={}
|
||||
|
||||
def obtain_query(self):
|
||||
def obtain_query(self, ignore_csrf_token=True):
|
||||
|
||||
self.query={}
|
||||
|
||||
self.query=request.query.decode()
|
||||
|
||||
if ignore_csrf_token==False and no_csrf==False:
|
||||
check_csrf(self.query)
|
||||
|
||||
# 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):
|
||||
|
||||
|
|
@ -131,3 +134,28 @@ class GetPostFiles:
|
|||
def 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 bottle import request
|
||||
import sys
|
||||
import re
|
||||
|
||||
class SimpleList:
|
||||
|
||||
|
|
@ -78,6 +79,8 @@ class SimpleList:
|
|||
|
||||
self.jln='<br />'
|
||||
|
||||
self.ajax=False
|
||||
|
||||
def restore_fields(self):
|
||||
self.fields=self.model.fields.keys()
|
||||
|
||||
|
|
@ -191,15 +194,41 @@ class SimpleList:
|
|||
|
||||
#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='')
|
||||
|
||||
self.begin_page=str(self.begin_page)
|
||||
|
||||
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()
|
||||
|
||||
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:
|
||||
initial_link=add_get_parameters(link, **{variable: '0'});
|
||||
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={}
|
||||
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ class DbPlugin(object):
|
|||
def setup(self, app):
|
||||
''' Make sure that other installed plugins don't affect the same keyword argument.'''
|
||||
for other in app.plugins:
|
||||
if not isinstance(other, LoginPlugin): continue
|
||||
if not isinstance(other, DbPlugin): continue
|
||||
if other.keyword == self.keyword:
|
||||
raise PluginError("Found another login plugin with "\
|
||||
"conflicting settings (non-unique keyword).")
|
||||
|
|
|
|||
|
|
@ -30,7 +30,14 @@
|
|||
<td class="options_td">${ extra_field }</td>
|
||||
% endfor
|
||||
</tr>
|
||||
<%
|
||||
pos=0
|
||||
%>
|
||||
% for row in list:
|
||||
<%
|
||||
if not 'pos' in row:
|
||||
row['pos']=pos
|
||||
%>
|
||||
<tr class="row_list">
|
||||
% for field in simplelist.fields_showed:
|
||||
% if simplelist.model.fields[field].escape==True:
|
||||
|
|
@ -44,6 +51,9 @@
|
|||
<td class="options_td">${ simplelist.set_options(extra_field_func, row)|n }</td>
|
||||
% endfor
|
||||
</tr>
|
||||
<%
|
||||
pos+=1
|
||||
%>
|
||||
% endfor
|
||||
</table>
|
||||
<p>
|
||||
|
|
|
|||
|
|
@ -66,6 +66,27 @@ class CheckForm():
|
|||
self.error+=1
|
||||
|
||||
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'):
|
||||
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ p {
|
|||
/* border:solid #cccccc;
|
||||
border-width:0px 1px 1px 0px;*/
|
||||
box-sizing: border-box;
|
||||
padding-bottom: 100px;
|
||||
/* padding-bottom: 100px;*/
|
||||
overflow:hidden;
|
||||
}
|
||||
|
||||
|
|
@ -256,6 +256,13 @@ p {
|
|||
overflow:auto;
|
||||
border: solid #cbcbcb;
|
||||
border-width: 0px 0px 1px 0px;
|
||||
min-height: 90vh;
|
||||
}
|
||||
|
||||
.content_admin i {
|
||||
|
||||
margin-right: 10px;
|
||||
|
||||
}
|
||||
|
||||
.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">
|
||||
<nav id="menu" class="nav-collapse">
|
||||
<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:
|
||||
% if type(menu[module]).__name__=='list':
|
||||
% 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
|
||||
% else:
|
||||
% if menu[module]!="":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue