Fix in dateform

This commit is contained in:
Antonio de la Rosa 2025-12-03 20:52:07 +01:00
parent f6d53cbd09
commit 6a0508328f
3 changed files with 37 additions and 56 deletions

View file

@ -2,11 +2,11 @@ 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, hook, error, debug, redirect, template
from settings import config
#from beaker.middleware import SessionMiddleware
from mimetypes import guess_type
from cuchulu.libraries.db.webmodel import WebModel
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.wsgiapp import app
@ -17,8 +17,6 @@ except:
class modules_external:
extra_apps={}
#from cuchulu.libraries.sessions import after_session
modules_pass=False
#app.reset()
@ -28,10 +26,10 @@ modules_pass=False
#Prepare links for static.
#WARNING: only use this feature in development, not in production.
#def create_app():
workdir=os.getcwd()
arr_module_path={}
"""
if config.session_enabled==True:
#Create dir for sessions
@ -39,12 +37,9 @@ if config.session_enabled==True:
if not os.path.isdir(config.session_opts['session.data_dir']):
os.makedirs(config.session_opts['session.data_dir'], 0o700, True)
"""
@app.hook('after_request')
def clean_session():
after_session()
"""
"""
error_reporting=False
if hasattr(config, 'error_reporting'):
@ -63,33 +58,6 @@ def prepare_app():
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={}
if len(modules_external.extra_apps)>0:
@ -167,8 +135,7 @@ application=app
# Load modules
try:
#from settings import modules
prepare_app()
except:
@ -179,7 +146,7 @@ except:
def catch_errors(all='/'):
try:
from pathlib import Path
#from settings import modules
import time
prepare_app()
p=Path('app.py')
@ -200,8 +167,6 @@ if config.yes_static==True:
mimetype=guess_type(workdir+'/themes/'+config.theme+'/media/'+filename)
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>')
def send_static_module(module, filename):

View file

@ -1,7 +1,7 @@
#!/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

View file

@ -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" 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:
<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="text" 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="23" name="${form}_hour" id="time_${form}_hour" class="form_hour" value="${h}" 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="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
<input type="hidden" name="${form}" id="time_${form}" value="" />
<script language="javascript">
$(document).submit(function () {
year=$("#time_${form}_year").val().toString();
/*year=$("#time_${form}_year").val().toString();
month=$("#time_${form}_month").val().toString();
day=$("#time_${form}_day").val().toString();
year=add_extra_length(year, 4);
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:
hour=$("#time_${form}_hour").val().toString();
/*hour=$("#time_${form}_hour").val().toString();
minute=$("#time_${form}_minute").val().toString();
second=$("#time_${form}_second").val().toString();
hour=add_extra_length(hour, 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: