Fixes in sql connection hook
This commit is contained in:
parent
879aa66823
commit
a2481580a9
8 changed files with 57 additions and 33 deletions
|
|
@ -3,7 +3,8 @@
|
||||||
#from paramecio2.libraries.db.webmodel import PhangoField
|
#from paramecio2.libraries.db.webmodel import PhangoField
|
||||||
from paramecio2.libraries.db.corefields import IntegerField
|
from paramecio2.libraries.db.corefields import IntegerField
|
||||||
from paramecio2.libraries.db.coreforms import SelectModelForm
|
from paramecio2.libraries.db.coreforms import SelectModelForm
|
||||||
from paramecio.citoplasma.httputils import GetPostFiles
|
#from paramecio.citoplasma.httputils import GetPostFiles
|
||||||
|
from flask import request
|
||||||
|
|
||||||
class ParentField(IntegerField):
|
class ParentField(IntegerField):
|
||||||
|
|
||||||
|
|
@ -27,9 +28,11 @@ class ParentField(IntegerField):
|
||||||
if self.model!=None:
|
if self.model!=None:
|
||||||
if self.model.updated==True:
|
if self.model.updated==True:
|
||||||
if self.model.name_field_id in self.model.post:
|
if self.model.name_field_id in self.model.post:
|
||||||
GetPostFiles.obtain_get()
|
#GetPostFiles.obtain_get()
|
||||||
|
|
||||||
|
#model_id=GetPostFiles.get.get(self.model.name_field_id, '0')
|
||||||
|
|
||||||
model_id=GetPostFiles.get.get(self.model.name_field_id, '0')
|
model_id=request.args.get(self.model.name_field_id, '0')
|
||||||
|
|
||||||
if model_id==value:
|
if model_id==value:
|
||||||
self.error=True
|
self.error=True
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,8 @@ class SqlClass:
|
||||||
if self.connection['db_type']=='pymysql':
|
if self.connection['db_type']=='pymysql':
|
||||||
|
|
||||||
import pymysql.cursors
|
import pymysql.cursors
|
||||||
|
pymysql.install_as_MySQLdb
|
||||||
|
SqlClass.pymysql_install=True
|
||||||
SqlClass.cursors_connect=pymysql.cursors.DictCursor
|
SqlClass.cursors_connect=pymysql.cursors.DictCursor
|
||||||
else:
|
else:
|
||||||
import MySQLdb.cursors
|
import MySQLdb.cursors
|
||||||
|
|
|
||||||
|
|
@ -107,6 +107,10 @@ class PTemplate:
|
||||||
|
|
||||||
self.filters[filter_name.__name__]=filter_name
|
self.filters[filter_name.__name__]=filter_name
|
||||||
|
|
||||||
|
def add_css_home_local(file_css, module):
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
env=env_theme(__file__)
|
env=env_theme(__file__)
|
||||||
|
|
||||||
standard_t=PTemplate(env)
|
standard_t=PTemplate(env)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
from flask import Blueprint
|
||||||
|
from paramecio2.libraries.mtemplates import PTemplate, env_theme
|
||||||
|
|
||||||
|
admin_app=Blueprint('admin_app', __name__, static_folder='static')
|
||||||
|
|
||||||
|
env=env_theme(__file__)
|
||||||
|
|
||||||
|
t=PTemplate(env)
|
||||||
|
|
@ -4,11 +4,13 @@ from paramecio2.modules.admin.models.admin import UserAdmin
|
||||||
from paramecio2.libraries.generate_admin_class import GenerateAdminClass
|
from paramecio2.libraries.generate_admin_class import GenerateAdminClass
|
||||||
from paramecio2.libraries.i18n import I18n
|
from paramecio2.libraries.i18n import I18n
|
||||||
from paramecio2.libraries.db.coreforms import SelectForm
|
from paramecio2.libraries.db.coreforms import SelectForm
|
||||||
|
import copy
|
||||||
|
from paramecio2.modules.admin import admin_app, t as admin_t
|
||||||
|
|
||||||
|
t=copy.copy(admin_t)
|
||||||
|
|
||||||
def admin(**args):
|
@admin_app.route('/admin/ausers/', methods=['GET', 'POST'])
|
||||||
|
def ausers():
|
||||||
t=args['t']
|
|
||||||
|
|
||||||
connection=g.connection
|
connection=g.connection
|
||||||
|
|
||||||
|
|
@ -25,7 +27,7 @@ def admin(**args):
|
||||||
user_admin.check_user=False
|
user_admin.check_user=False
|
||||||
user_admin.check_email=False
|
user_admin.check_email=False
|
||||||
|
|
||||||
url=url_for('.admin', module='ausers')
|
url=url_for('admin_app.ausers')
|
||||||
|
|
||||||
admin=GenerateAdminClass(user_admin, url, t)
|
admin=GenerateAdminClass(user_admin, url, t)
|
||||||
|
|
||||||
|
|
@ -37,4 +39,10 @@ def admin(**args):
|
||||||
|
|
||||||
form_admin=admin.show()
|
form_admin=admin.show()
|
||||||
|
|
||||||
return form_admin
|
if type(form_admin).__name__=='str':
|
||||||
|
|
||||||
|
return t.load_template('content.phtml', title=I18n.lang('admin', 'users_edit', 'Users edit'), contents=form_admin, path_module='/admin/ausers')
|
||||||
|
else:
|
||||||
|
|
||||||
|
return form_admin
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
from flask import Blueprint, redirect, session, url_for, request, g, make_response, abort
|
from flask import Blueprint, redirect, session, url_for, request, g, make_response, abort
|
||||||
from settings import config
|
from settings import config
|
||||||
from paramecio2.libraries.mtemplates import PTemplate, env_theme
|
|
||||||
from paramecio2.libraries.i18n import I18n
|
from paramecio2.libraries.i18n import I18n
|
||||||
from paramecio2.libraries.formsutils import show_form, generate_csrf, set_extra_forms_user, pass_values_to_form
|
from paramecio2.libraries.formsutils import show_form, generate_csrf, set_extra_forms_user, pass_values_to_form
|
||||||
from paramecio2.libraries.db.webmodel import WebModel
|
from paramecio2.libraries.db.webmodel import WebModel
|
||||||
|
|
@ -10,10 +9,9 @@ from time import time
|
||||||
import os, sys
|
import os, sys
|
||||||
from importlib import import_module
|
from importlib import import_module
|
||||||
from paramecio2.libraries.config_admin import config_admin
|
from paramecio2.libraries.config_admin import config_admin
|
||||||
|
import copy
|
||||||
env=env_theme(__file__)
|
from os import path
|
||||||
|
from paramecio2.modules.admin import admin_app, t
|
||||||
t=PTemplate(env)
|
|
||||||
|
|
||||||
yes_recovery_login=False
|
yes_recovery_login=False
|
||||||
email_address='localhost'
|
email_address='localhost'
|
||||||
|
|
@ -25,7 +23,7 @@ if hasattr(config, 'email_address'):
|
||||||
email_address=config.email_address
|
email_address=config.email_address
|
||||||
|
|
||||||
|
|
||||||
admin_app=Blueprint('admin_app', __name__, static_folder='static')
|
#admin_app=Blueprint('admin_app', __name__, static_folder='static')
|
||||||
|
|
||||||
@admin_app.before_request
|
@admin_app.before_request
|
||||||
def admin_prepare():
|
def admin_prepare():
|
||||||
|
|
@ -82,22 +80,24 @@ for app_load in config_admin:
|
||||||
if len(app_load)==3:
|
if len(app_load)==3:
|
||||||
|
|
||||||
arr_modules_admin[app_load[2]+'/']=import_module(app_load[1])
|
arr_modules_admin[app_load[2]+'/']=import_module(app_load[1])
|
||||||
|
#arr_modules_admin[app_load[2]+'/'].admin=admin_app.route(arr_modules_admin[app_load[2]+'/'])(arr_modules_admin[app_load[2]+'/'].admin)
|
||||||
#print(app_load[1])
|
#print(app_load[1])
|
||||||
elif len(app_load)==4:
|
elif len(app_load)==4:
|
||||||
|
|
||||||
arr_modules_admin[app_load[2]+'/'+app_load[3]]=import_module(app_load[1])
|
arr_modules_admin[app_load[2]+'/'+app_load[3]]=import_module(app_load[1])
|
||||||
|
|
||||||
#print(app_load[1])
|
#print(app_load[1])
|
||||||
|
|
||||||
|
@admin_app.route('/admin/')
|
||||||
|
def admin():
|
||||||
|
return t.load_template('home.phtml', title=I18n.lang('admin', 'paramecio_admin', 'Paramecio admin'))
|
||||||
|
|
||||||
|
"""
|
||||||
@admin_app.route('/admin/')
|
@admin_app.route('/admin/')
|
||||||
@admin_app.route('/admin/<module>', methods=['GET', 'POST'])
|
@admin_app.route('/admin/<module>', methods=['GET', 'POST'])
|
||||||
@admin_app.route('/admin/<module>/<submodule>', methods=['GET', 'POST'])
|
@admin_app.route('/admin/<module>/<submodule>', methods=['GET', 'POST'])
|
||||||
def admin(module='', submodule=''):
|
def admin(module='', submodule=''):
|
||||||
|
|
||||||
"""
|
|
||||||
if 'login_admin' not in session:
|
|
||||||
return redirect(url_for('admin_app.login'))
|
|
||||||
"""
|
|
||||||
|
|
||||||
if module=='':
|
if module=='':
|
||||||
|
|
||||||
return t.load_template('home.phtml', title=I18n.lang('admin', 'paramecio_admin', 'Paramecio admin'))
|
return t.load_template('home.phtml', title=I18n.lang('admin', 'paramecio_admin', 'Paramecio admin'))
|
||||||
|
|
@ -108,6 +108,15 @@ def admin(module='', submodule=''):
|
||||||
|
|
||||||
if path_module in arr_modules_admin:
|
if path_module in arr_modules_admin:
|
||||||
|
|
||||||
|
t_mod=copy.copy(t)
|
||||||
|
|
||||||
|
templates_path=path.dirname(arr_modules_admin[module+'/'+submodule].__file__).replace('/admin', '')+'/templates'
|
||||||
|
|
||||||
|
try:
|
||||||
|
index_value = t_mod.env.directories.index(templates_path)
|
||||||
|
except ValueError:
|
||||||
|
t_mod.env.directories.insert(0, templates_path)
|
||||||
|
|
||||||
content=arr_modules_admin[path_module].admin(t=t)
|
content=arr_modules_admin[path_module].admin(t=t)
|
||||||
|
|
||||||
if type(content).__name__=='str':
|
if type(content).__name__=='str':
|
||||||
|
|
@ -121,6 +130,7 @@ def admin(module='', submodule=''):
|
||||||
else:
|
else:
|
||||||
abort(404)
|
abort(404)
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
@admin_app.route('/admin/logout')
|
@admin_app.route('/admin/logout')
|
||||||
def logout():
|
def logout():
|
||||||
|
|
|
||||||
|
|
@ -5,4 +5,4 @@ from paramecio2.libraries.i18n import I18n
|
||||||
|
|
||||||
config_admin.append([I18n.lang('admin', 'users', 'Users')])
|
config_admin.append([I18n.lang('admin', 'users', 'Users')])
|
||||||
|
|
||||||
config_admin.append([I18n.lang('admin', 'users_edit', 'Users edit'), 'paramecio2.modules.admin.admin.ausers', 'ausers'])
|
config_admin.append([I18n.lang('admin', 'users_edit', 'Users edit'), 'paramecio2.modules.admin.admin.ausers', 'admin_app.ausers'])
|
||||||
|
|
|
||||||
|
|
@ -57,18 +57,8 @@
|
||||||
|
|
||||||
%>
|
%>
|
||||||
|
|
||||||
<li><a href="${url_for('.admin', module=admin[2])}" class="${class_selected}"> <i class="fa fa-circle-o" aria-hidden="true"></i>${admin[0]}</a></li>
|
<li><a href="${url_for(admin[2])}" class="${class_selected}"> <i class="fa fa-circle-o" aria-hidden="true"></i>${admin[0]}</a></li>
|
||||||
|
|
||||||
% elif len(admin)==3:
|
|
||||||
<%
|
|
||||||
|
|
||||||
if admin[2]+'/'+admin[3]==path_module:
|
|
||||||
class_selected='selected_menu'
|
|
||||||
|
|
||||||
%>
|
|
||||||
|
|
||||||
<li><a href="${url_for('.admin', module=admin[2], submodule=admin[3])}" class="${class_selected}"> <i class="fa fa-circle-o" aria-hidden="true"></i>${admin[0]}</a></li>
|
|
||||||
|
|
||||||
% elif len(admin)==1:
|
% elif len(admin)==1:
|
||||||
|
|
||||||
<li><div class="father_admin">${admin[0]}</div></li>
|
<li><div class="father_admin">${admin[0]}</div></li>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue