Little fixes

This commit is contained in:
Antonio de la Rosa 2016-01-14 02:24:13 +01:00
parent 4b284dce0d
commit 6770a442e2
4 changed files with 44 additions and 5 deletions

View file

@ -129,7 +129,7 @@ def checkdatetime(y, m, d, h, mi, s):
except:
return False
# Obtain the actual time in gmt
# Obtain the actual time in local or gmt
def now(gmt=False):
@ -187,6 +187,10 @@ def format_date(timeform):
return format_datetime(format_date_txt, timeform, time.localtime)
def format_fulldate(timeform):
return format_datetime(format_date_txt+' '+format_time_txt, timeform, time.localtime)
def sum_utc(timestamp, offset):
return timestamp+offset

View file

@ -29,6 +29,10 @@ class ptemplate:
template_context=None
# A simple method used in internal things of paramecio
show_basic_template=True
def __init__(self, module):
module=path.dirname(module)

View file

@ -477,6 +477,28 @@ class WebModel:
return False
def set_conditions(self, sql_text, values:list) -> None:
self.conditions=[sql_text, values]
def set_order(self, order:list, position:list) -> None:
order=[]
for o in enumerate(order):
order.append('order by '+order[o]+' '+position[o])
self.order=", ".join(order)
def set_limit(self, limit: tuple) -> None:
sql_limit=str(limit[0])
if len(limit)>1:
sql_limit+=', '+str(limit[1])
self.limit='limit '+sql_limit
# Method for create sql tables

View file

@ -38,6 +38,10 @@ t=ptemplate(__file__)
@post('/'+config.admin_folder+'/<module>/<submodule>')
def home(module='', submodule=''):
# A simple boolean used for show or not the code of admin module in standard template
ptemplate.show_basic_template=True
if submodule!='':
module+='/'+submodule
@ -101,11 +105,16 @@ def home(module='', submodule=''):
except ImportError:
return "No exists admin module"
return t.load_template('admin/content.html', title=menu[module][0], content_index=new_module.admin(t), menu=menu, lang_selected=lang_selected, arr_i18n=I18n.dict_i18n)
content_index=new_module.admin(t)
if ptemplate.show_basic_template==True:
return t.load_template('admin/content.html', title=menu[module][0], content_index=content_index, menu=menu, lang_selected=lang_selected, arr_i18n=I18n.dict_i18n)
else:
return content_index
else:
return t.load_template('admin/index.html', title=I18n.lang('admin', 'welcome_to_paramecio', 'Welcome to Paramecio Admin!!!'), menu=menu, lang_selected=lang_selected, arr_i18n=I18n.dict_i18n)