Fix in dateform
This commit is contained in:
parent
f6d53cbd09
commit
6a0508328f
3 changed files with 37 additions and 56 deletions
|
|
@ -2,11 +2,11 @@ import os, sys, traceback, inspect, resource
|
||||||
from importlib import import_module
|
from importlib import import_module
|
||||||
from bottle import route, get, post, run, default_app, abort, request, response, static_file, load, hook, error, debug, redirect, template
|
from bottle import route, get, post, run, default_app, abort, request, response, static_file, load, hook, error, debug, redirect, template
|
||||||
from settings import config
|
from settings import config
|
||||||
#from beaker.middleware import SessionMiddleware
|
|
||||||
from mimetypes import guess_type
|
from mimetypes import guess_type
|
||||||
from cuchulu.libraries.db.webmodel import WebModel
|
from cuchulu.libraries.db.webmodel import WebModel
|
||||||
from cuchulu.libraries.datetime import set_timezone
|
from cuchulu.libraries.datetime import set_timezone
|
||||||
#from itsdangerous import JSONWebSignatureSerializer
|
|
||||||
from cuchulu.libraries.keyutils import create_key_encrypt, create_key_encrypt_256, create_key
|
from cuchulu.libraries.keyutils import create_key_encrypt, create_key_encrypt_256, create_key
|
||||||
from cuchulu.wsgiapp import app
|
from cuchulu.wsgiapp import app
|
||||||
|
|
||||||
|
|
@ -17,8 +17,6 @@ except:
|
||||||
class modules_external:
|
class modules_external:
|
||||||
extra_apps={}
|
extra_apps={}
|
||||||
|
|
||||||
#from cuchulu.libraries.sessions import after_session
|
|
||||||
|
|
||||||
modules_pass=False
|
modules_pass=False
|
||||||
|
|
||||||
#app.reset()
|
#app.reset()
|
||||||
|
|
@ -28,10 +26,10 @@ modules_pass=False
|
||||||
#Prepare links for static.
|
#Prepare links for static.
|
||||||
#WARNING: only use this feature in development, not in production.
|
#WARNING: only use this feature in development, not in production.
|
||||||
|
|
||||||
#def create_app():
|
|
||||||
workdir=os.getcwd()
|
workdir=os.getcwd()
|
||||||
arr_module_path={}
|
arr_module_path={}
|
||||||
|
|
||||||
|
"""
|
||||||
if config.session_enabled==True:
|
if config.session_enabled==True:
|
||||||
#Create dir for sessions
|
#Create dir for sessions
|
||||||
|
|
||||||
|
|
@ -39,11 +37,8 @@ if config.session_enabled==True:
|
||||||
|
|
||||||
if not os.path.isdir(config.session_opts['session.data_dir']):
|
if not os.path.isdir(config.session_opts['session.data_dir']):
|
||||||
os.makedirs(config.session_opts['session.data_dir'], 0o700, True)
|
os.makedirs(config.session_opts['session.data_dir'], 0o700, True)
|
||||||
"""
|
|
||||||
@app.hook('after_request')
|
"""
|
||||||
def clean_session():
|
|
||||||
after_session()
|
|
||||||
"""
|
|
||||||
|
|
||||||
error_reporting=False
|
error_reporting=False
|
||||||
|
|
||||||
|
|
@ -63,33 +58,6 @@ def prepare_app():
|
||||||
|
|
||||||
module_loaded=None
|
module_loaded=None
|
||||||
|
|
||||||
#Getting paths for loaded modules for use in media load files
|
|
||||||
"""
|
|
||||||
for module in config.modules:
|
|
||||||
|
|
||||||
#controller_path=sys.modules[module]
|
|
||||||
|
|
||||||
controller_base=sys.modules[module].__path__[0]
|
|
||||||
|
|
||||||
base_module=module.split('.')[-1]
|
|
||||||
|
|
||||||
arr_module_path[base_module]=controller_base
|
|
||||||
"""
|
|
||||||
|
|
||||||
#app.add_hook('before_request', print_memory)
|
|
||||||
"""
|
|
||||||
for added_app in config.apps:
|
|
||||||
|
|
||||||
a=import_module(added_app)
|
|
||||||
#print(added_app, file=sys.stdout)
|
|
||||||
app_name=getattr(a, config.apps[added_app][0])
|
|
||||||
|
|
||||||
app.mount(config.apps[added_app][1], app_name)
|
|
||||||
#print(added_app)
|
|
||||||
#print(a.__path__[0])
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
app_mounts={}
|
app_mounts={}
|
||||||
|
|
||||||
if len(modules_external.extra_apps)>0:
|
if len(modules_external.extra_apps)>0:
|
||||||
|
|
@ -168,7 +136,6 @@ application=app
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
#from settings import modules
|
|
||||||
prepare_app()
|
prepare_app()
|
||||||
|
|
||||||
except:
|
except:
|
||||||
|
|
@ -179,7 +146,7 @@ except:
|
||||||
def catch_errors(all='/'):
|
def catch_errors(all='/'):
|
||||||
try:
|
try:
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
#from settings import modules
|
|
||||||
import time
|
import time
|
||||||
prepare_app()
|
prepare_app()
|
||||||
p=Path('app.py')
|
p=Path('app.py')
|
||||||
|
|
@ -201,8 +168,6 @@ if config.yes_static==True:
|
||||||
|
|
||||||
return static_file(filename, root=workdir+'/themes/'+config.theme+'/media/', mimetype=mimetype[0])
|
return static_file(filename, root=workdir+'/themes/'+config.theme+'/media/', mimetype=mimetype[0])
|
||||||
|
|
||||||
#def add_func_static_module(module):
|
|
||||||
|
|
||||||
@app.route('/mediafrom/<module>/<filename:path>')
|
@app.route('/mediafrom/<module>/<filename:path>')
|
||||||
def send_static_module(module, filename):
|
def send_static_module(module, filename):
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Cuchulufm is a series of wrappers for Flask, mako and others and construct a simple headless cms.
|
Cuchulufm is a series of wrappers for Bottle, mako and others and construct a simple headless cms.
|
||||||
|
|
||||||
Copyright (C) 2023 Antonio de la Rosa Caballero
|
Copyright (C) 2023 Antonio de la Rosa Caballero
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,38 +1,54 @@
|
||||||
${add_js_home_local('jquery.min.js', 'admin')}
|
${add_js('jquery.min.js', 'admin')}
|
||||||
|
|
||||||
<input type="number" min="1" max="31" name="${form}_day" id="time_${form}_day" class="form_day" value="${d}" size="2" maxlength="2"/>
|
<!--<input type="number" min="1" max="31" name="${form}_day" id="time_${form}_day" class="form_day" value="${d}" size="2" maxlength="2"/>
|
||||||
<input type="number" min="1" max="12" name="${form}_month" id="time_${form}_month" class="form_month" value="${m}" size="2" maxlength="2"/>
|
<input type="number" min="1" max="12" name="${form}_month" id="time_${form}_month" class="form_month" value="${m}" size="2" maxlength="2"/>
|
||||||
<input type="number" name="${form}_year" id="time_${form}_year" class="form_year" value="${y}" size="4" maxlength="4"/>
|
<input type="number" name="${form}_year" id="time_${form}_year" class="form_year" value="${y}" size="4" maxlength="4"/>-->
|
||||||
|
<%
|
||||||
|
|
||||||
|
date=''
|
||||||
|
|
||||||
|
if d!='':
|
||||||
|
date='-'.join((str(y), str(m), str(d)))
|
||||||
|
|
||||||
|
time=''
|
||||||
|
|
||||||
|
if h!='':
|
||||||
|
time=':'.join((str(h), str(min)))
|
||||||
|
|
||||||
|
%>
|
||||||
|
<input type="date" value="${date}" name="${form}_date" id="${form}_date" />
|
||||||
% if yes_time==True:
|
% if yes_time==True:
|
||||||
<input type="text" min="0" max="23" name="${form}_hour" id="time_${form}_hour" class="form_hour" value="${h}" size="2" maxlength="2"/>
|
<!--<input type="number" min="0" max="23" name="${form}_hour" id="time_${form}_hour" class="form_hour" value="${h}" size="2" maxlength="2"/>
|
||||||
<input type="text" min="0" max="60" name="${form}_minute" id="time_${form}_minute" class="form_minute" value="${min}" size="2" maxlength="2"/>
|
<input type="number" min="0" max="60" name="${form}_minute" id="time_${form}_minute" class="form_minute" value="${min}" size="2" maxlength="2"/>
|
||||||
<input type="text" min="0" max="60" name="${form}_second" id="time_${form}_second" class="form_second" value="${s}" size="2" maxlength="2"/>
|
<input type="number" min="0" max="60" name="${form}_second" id="time_${form}_second" class="form_second" value="${s}" size="2" maxlength="2"/>-->
|
||||||
|
<input type="time" value="${time}" name="${form}_time" id="${form}_time" />
|
||||||
% endif
|
% endif
|
||||||
<input type="hidden" name="${form}" id="time_${form}" value="" />
|
<input type="hidden" name="${form}" id="time_${form}" value="" />
|
||||||
|
|
||||||
<script language="javascript">
|
<script language="javascript">
|
||||||
$(document).submit(function () {
|
$(document).submit(function () {
|
||||||
|
|
||||||
year=$("#time_${form}_year").val().toString();
|
/*year=$("#time_${form}_year").val().toString();
|
||||||
month=$("#time_${form}_month").val().toString();
|
month=$("#time_${form}_month").val().toString();
|
||||||
day=$("#time_${form}_day").val().toString();
|
day=$("#time_${form}_day").val().toString();
|
||||||
|
|
||||||
year=add_extra_length(year, 4);
|
year=add_extra_length(year, 4);
|
||||||
month=add_extra_length(month, 2);
|
month=add_extra_length(month, 2);
|
||||||
day=add_extra_length(day, 2);
|
day=add_extra_length(day, 2); */
|
||||||
|
|
||||||
final_time=year+month+day
|
//final_time=year+month+day
|
||||||
|
final_time=$('#${form}_date').val().replace(/-/g, '');
|
||||||
|
|
||||||
% if yes_time==True:
|
% if yes_time==True:
|
||||||
hour=$("#time_${form}_hour").val().toString();
|
/*hour=$("#time_${form}_hour").val().toString();
|
||||||
minute=$("#time_${form}_minute").val().toString();
|
minute=$("#time_${form}_minute").val().toString();
|
||||||
second=$("#time_${form}_second").val().toString();
|
second=$("#time_${form}_second").val().toString();
|
||||||
|
|
||||||
hour=add_extra_length(hour, 2);
|
hour=add_extra_length(hour, 2);
|
||||||
minute=add_extra_length(minute, 2);
|
minute=add_extra_length(minute, 2);
|
||||||
second=add_extra_length(second, 2);
|
second=add_extra_length(second, 2); */
|
||||||
|
|
||||||
final_time+=final_time;
|
final_time+=$('#${form}_time').val().replace(':', '')+'00';
|
||||||
|
|
||||||
% else:
|
% else:
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue