diff --git a/paramecio/modules/admin/index.py b/paramecio/modules/admin/index.py index 72d8b94..7d8ca13 100644 --- a/paramecio/modules/admin/index.py +++ b/paramecio/modules/admin/index.py @@ -60,12 +60,22 @@ for k, v in menu.items(): #print(d) +t=PTemplate(env) + +num_template=1 + +if hasattr(config, 'admin_templates_index'): + + t.env.directories.insert(num_template, config.admin_templates_index) + num_template+=1 + + @app.get('/'+config.admin_folder) @app.get('/'+config.admin_folder+'/') @app.post('/'+config.admin_folder+'/') @app.get('/'+config.admin_folder+'//') @app.post('/'+config.admin_folder+'//') -def home(module='', submodule=''): +def home(module='', submodule='', t=t): # A simple boolean used for show or not the code of admin module in standard template @@ -74,8 +84,6 @@ def home(module='', submodule=''): #Fix, make local variable - t=PTemplate(env) - t.add_filter(make_admin_url) t.show_basic_template=True @@ -118,8 +126,14 @@ def home(module='', submodule=''): #t.env=t.env_theme(path.dirname(__file__)) - t.env.directories.insert(1, path.dirname(module_imported[module].__file__).replace('/admin', '')+'/templates') - #print(t.env.directories) + templates_path=path.dirname(module_imported[module].__file__).replace('/admin', '')+'/templates' + + try: + index_value = t.env.directories.index(templates_path) + except ValueError: + t.env.directories.insert(num_template, templates_path) + + print(t.env.directories) #if config.reloader: #reload(new_module) diff --git a/tests/webmodeltest.py b/tests/webmodeltest.py index 487a4b4..e6da8f4 100644 --- a/tests/webmodeltest.py +++ b/tests/webmodeltest.py @@ -183,6 +183,27 @@ class TestWebModelMethods(unittest.TestCase): self.assertTrue(model.drop()) connection.close() + + def test_functions(self): + + print('Test functions') + + connection=WebModel.connection() + model=ExampleModel(connection) + + sql=model.create_table() + + self.assertTrue(model.query(sql)) + + cur=model.set_conditions('where id=%s', [4]).select() + + self.assertTrue(cur) + + cur.close() + + self.assertTrue(model.drop()) + + connection.close() def test_zcheck_1_foreignkeys(self):