diff --git a/paramecio/citoplasma/lists.py b/paramecio/citoplasma/lists.py index c52c5e9..45dc01a 100644 --- a/paramecio/citoplasma/lists.py +++ b/paramecio/citoplasma/lists.py @@ -170,7 +170,7 @@ class SimpleList: self.model.limit='limit '+str(begin_page)+','+str(self.limit_pages) - list_items=self.model.select(self.fields) + list_items=self.model.select(self.fields, True) pages=Pages.show( begin_page, total_elements, num_elements, link ,initial_num_pages=self.initial_num_pages, variable='begin_page', label='', func_jscript='') diff --git a/paramecio/cromosoma/corefields.py b/paramecio/cromosoma/corefields.py index 05051cd..e16266d 100644 --- a/paramecio/cromosoma/corefields.py +++ b/paramecio/cromosoma/corefields.py @@ -160,8 +160,8 @@ class BooleanField(IntegerField): value=int(value) if value==0: - value=self.yes_text - else: value=self.no_text + else: + value=self.yes_text return str(value) diff --git a/paramecio/cromosoma/webmodel.py b/paramecio/cromosoma/webmodel.py index 2b23c0d..1be3d6a 100644 --- a/paramecio/cromosoma/webmodel.py +++ b/paramecio/cromosoma/webmodel.py @@ -510,7 +510,7 @@ class WebModel: conditions[0]+=" AND `"+table_name+"`.`"+self.fields[field].identifier_field+"`=`"+self.name+"`.`"+field+"`" - sql= "select count(`"+field_to_count+"`) from "+", ".join(tables_to_select)+conditions[0] + sql= "select count(`"+field_to_count+"`) from "+", ".join(tables_to_select)+' '+conditions[0] cursor=self.sqlclass.query(sql, conditions[1], self.connection_id) diff --git a/paramecio/index.py b/paramecio/index.py index 93a8c74..9283906 100644 --- a/paramecio/index.py +++ b/paramecio/index.py @@ -1,6 +1,6 @@ import os, sys, traceback, inspect, resource from importlib import import_module -from bottle import route, get, post, run, default_app, abort, request, response, static_file, load +from bottle import route, get, post, run, default_app, abort, request, response, static_file, load, hook from settings import config, modules from beaker.middleware import SessionMiddleware from mimetypes import guess_type @@ -167,6 +167,12 @@ if config.session_enabled==True: """ app = SessionMiddleware(app, config.session_opts, environ_key=config.cookie_name) +# Clean last slash + +@hook('before_request') +def strip_path(): + request.environ['PATH_INFO'] = request.environ['PATH_INFO'].rstrip('/') + def run_app(app): run(app=app, host=config.host, server=config.server_used, port=config.port, debug=config.debug, reloader=config.reloader) diff --git a/paramecio/modules/admin/index.py b/paramecio/modules/admin/index.py index 11a2fed..0957ac7 100644 --- a/paramecio/modules/admin/index.py +++ b/paramecio/modules/admin/index.py @@ -10,6 +10,7 @@ from bottle import get,post,response,request from settings import config from settings import config_admin from paramecio.citoplasma.lists import SimpleList +from paramecio.citoplasma.adminutils import get_menu, get_language from paramecio.citoplasma.generate_admin_class import GenerateAdminClass from paramecio.citoplasma.httputils import GetPostFiles from paramecio.cromosoma.formsutils import show_form, pass_values_to_form, set_extra_forms_user @@ -28,7 +29,7 @@ import copy load_lang(['paramecio', 'admin'], ['paramecio', 'common']) -key_encrypt=create_key_encrypt() +key_encrypt=config.key_encrypt #create_key_encrypt() module_admin=path.dirname(__file__) @@ -70,16 +71,9 @@ def home(module='', submodule=''): s['id']=s.get('id', 0) - s['lang']=s.get('lang', None) + lang_selected=get_language(s) - lang_selected=None - - if s['lang']!=None: - lang_selected=s['lang'] - else: - s['lang']=I18n.default_lang - - user_admin.conditions=['WHERE id=%s', [s['id']]] + user_admin.set_conditions('WHERE id=%s', [s['id']]) # Check if user id exists in session @@ -91,19 +85,7 @@ def home(module='', submodule=''): #Load menu - menu=OrderedDict() - - #modules_admin.append([I18n.lang('panel', 'servers_config', 'Server\'s configuration'), [I18n.lang('panel', 'servers_types', 'Server\'s types'), 'modules.panel.admin.types'], 'servers_config']) - - for mod in config_admin.modules_admin: - if type(mod[1]).__name__!='list': - menu[mod[2]]=mod - else: - - menu[mod[2]]=mod[0] - - for submod in mod[1]: - menu[submod[2]]=submod + menu=get_menu(config_admin.modules_admin) #pass if module in menu: @@ -285,7 +267,7 @@ def register(): user_admin=UserAdmin(connection) - user_admin.conditions=['WHERE privileges=%s', 2] + user_admin.conditions=['WHERE privileges=%s', [2]] c=user_admin.select_count() diff --git a/paramecio/modules/admin/templates/admin/home.html b/paramecio/modules/admin/templates/admin/home.html index 7699e9b..9be3fe9 100644 --- a/paramecio/modules/admin/templates/admin/home.html +++ b/paramecio/modules/admin/templates/admin/home.html @@ -1,3 +1,10 @@ +<%def name="check_menu(module)">\ + % if module[:1]=='/': +${module}\ + % else: +${'/admin/'+module}\ + % endif +%def>
@@ -44,7 +51,7 @@ ${HeaderHTML.header_home()|n} % for module in menu: % if type(menu[module]).__name__=='list': % if menu[module][0]!="": - ${menu[module][0]} + ${menu[module][0]} % endif % else: % if menu[module]!="":