Fixes in sql connection hook
This commit is contained in:
parent
879aa66823
commit
a2481580a9
8 changed files with 57 additions and 33 deletions
|
|
@ -1,6 +1,5 @@
|
|||
from flask import Blueprint, redirect, session, url_for, request, g, make_response, abort
|
||||
from settings import config
|
||||
from paramecio2.libraries.mtemplates import PTemplate, env_theme
|
||||
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.db.webmodel import WebModel
|
||||
|
|
@ -10,10 +9,9 @@ from time import time
|
|||
import os, sys
|
||||
from importlib import import_module
|
||||
from paramecio2.libraries.config_admin import config_admin
|
||||
|
||||
env=env_theme(__file__)
|
||||
|
||||
t=PTemplate(env)
|
||||
import copy
|
||||
from os import path
|
||||
from paramecio2.modules.admin import admin_app, t
|
||||
|
||||
yes_recovery_login=False
|
||||
email_address='localhost'
|
||||
|
|
@ -25,7 +23,7 @@ if hasattr(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
|
||||
def admin_prepare():
|
||||
|
|
@ -82,22 +80,24 @@ for app_load in config_admin:
|
|||
if len(app_load)==3:
|
||||
|
||||
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])
|
||||
elif len(app_load)==4:
|
||||
|
||||
arr_modules_admin[app_load[2]+'/'+app_load[3]]=import_module(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/<module>', methods=['GET', 'POST'])
|
||||
@admin_app.route('/admin/<module>/<submodule>', methods=['GET', 'POST'])
|
||||
def admin(module='', submodule=''):
|
||||
|
||||
"""
|
||||
if 'login_admin' not in session:
|
||||
return redirect(url_for('admin_app.login'))
|
||||
"""
|
||||
|
||||
if module=='':
|
||||
|
||||
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:
|
||||
|
||||
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)
|
||||
|
||||
if type(content).__name__=='str':
|
||||
|
|
@ -121,6 +130,7 @@ def admin(module='', submodule=''):
|
|||
else:
|
||||
abort(404)
|
||||
|
||||
"""
|
||||
|
||||
@admin_app.route('/admin/logout')
|
||||
def logout():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue