bugfix
This commit is contained in:
parent
439d72a61b
commit
fcb477d7ea
BIN
models/ragprogram.xlsx
Normal file
BIN
models/ragprogram.xlsx
Normal file
Binary file not shown.
46
rag/ragprogram.py
Normal file
46
rag/ragprogram.py
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
from appPublic.timeUtils import curDateString, dateadd
|
||||||
|
from ahserver.serverenv import get_serverenv
|
||||||
|
|
||||||
|
def set_program(request, program_type, quota):
|
||||||
|
db = DBPools()
|
||||||
|
dbname = get_serverenv('get_module_dbname')('rag')
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
u = await get_session_userinfo(request)
|
||||||
|
sql="select * from ragquote where orgid = ${orgid}$ order by enabled_date"
|
||||||
|
qs = await sor.sqlExe(sql, {'orgid': u.userorgid})
|
||||||
|
today = curDateString()
|
||||||
|
if len(qs) == 0:
|
||||||
|
if params_kw.program_type == 'free':
|
||||||
|
expired_date = dateadd(today, months=1)
|
||||||
|
else:
|
||||||
|
expired_date = '9999-12-31'
|
||||||
|
ns = {
|
||||||
|
"id": uuid(),
|
||||||
|
"orgid": u.userorgid,
|
||||||
|
"enabled_date": today,
|
||||||
|
"expired_date": expired_date,
|
||||||
|
'quota': params_kw.quota
|
||||||
|
}
|
||||||
|
await sor.C('ragquota', ns)
|
||||||
|
else:
|
||||||
|
lastq = qs[-1]
|
||||||
|
lastq.expired_date = today
|
||||||
|
await sor.U('ragquote', lastq.copy())
|
||||||
|
ns = {
|
||||||
|
"id": uuid(),
|
||||||
|
"orgid": u.userorgid,
|
||||||
|
"enabled_date": today,
|
||||||
|
"expired_date": expired_date,
|
||||||
|
'quota': params_kw.quota
|
||||||
|
}
|
||||||
|
await sor.C('ragquota', ns)
|
||||||
|
|
||||||
|
|
||||||
|
def get_programs(request):
|
||||||
|
db = DBPools()
|
||||||
|
dbname = get_serverenv('get_module_dbanme')('rag')
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
recs = await sor.R('ragprogram', {})
|
||||||
|
return recs
|
||||||
|
return []
|
||||||
|
|
||||||
81
wwwroot/programs.ui
Normal file
81
wwwroot/programs.ui
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
{
|
||||||
|
"widgettype":"DynamicColumn",
|
||||||
|
"options":{
|
||||||
|
"width":"100%"
|
||||||
|
"height":"100%"
|
||||||
|
},
|
||||||
|
"subwidgets":[
|
||||||
|
{% for p in get_rag_programs() %}
|
||||||
|
{
|
||||||
|
"widgettype":"VBox",
|
||||||
|
"options":{
|
||||||
|
"css":"card",
|
||||||
|
"width":"25%",
|
||||||
|
"cheight":10
|
||||||
|
},
|
||||||
|
"subwidgets":[
|
||||||
|
{
|
||||||
|
"widgettype":"Title5",
|
||||||
|
"options":{
|
||||||
|
"otext":"{{p.name}}"
|
||||||
|
"i18n":true,
|
||||||
|
"wrap":true,
|
||||||
|
"halign":"center",
|
||||||
|
"cheight":2
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"widgettype":"text",
|
||||||
|
"options":{
|
||||||
|
"otext":"{{p.description}}",
|
||||||
|
"i18n":true,
|
||||||
|
"wrap":true,
|
||||||
|
"halign":"left",
|
||||||
|
"cheight":2
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"widgettype":"HBox",
|
||||||
|
"options":{
|
||||||
|
"height":1.5
|
||||||
|
},
|
||||||
|
"subwidgets":[
|
||||||
|
{
|
||||||
|
"widgettype":"text",
|
||||||
|
"options":{
|
||||||
|
"otext":"可用磁盘容量",
|
||||||
|
"i18n":true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"widgettype":"text",
|
||||||
|
"options":{
|
||||||
|
"text":"{{p.quota / 1000000}}M"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"binds":[
|
||||||
|
{
|
||||||
|
"wid":"self",
|
||||||
|
"event":"click",
|
||||||
|
"actiontype":"urlwidget",
|
||||||
|
"target":"PopupWindow",
|
||||||
|
"popup_options":{
|
||||||
|
"anchor":"cc",
|
||||||
|
"width":"60%",
|
||||||
|
"height":"60%"
|
||||||
|
}
|
||||||
|
"options":{
|
||||||
|
"params":{
|
||||||
|
"selected_program":"p.id"
|
||||||
|
},
|
||||||
|
"url":"{{entire_url('./program_selected.dspy')}}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{% endfor %}
|
||||||
|
]
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user