1.1.3
This commit is contained in:
+7
-7
@@ -4,8 +4,10 @@ import os
|
||||
from datetime import datetime, timedelta
|
||||
from montydb.database import MontyDatabase
|
||||
|
||||
|
||||
class Manager:
|
||||
def __init__(self):
|
||||
def __init__(self,handler):
|
||||
self.handler = handler
|
||||
self.current_time = datetime.now().replace(hour=0, minute=0, second=0, microsecond=0) - timedelta(seconds=1)
|
||||
self.current_index = 0
|
||||
|
||||
@@ -36,7 +38,8 @@ class Manager:
|
||||
{"_id": id},
|
||||
{"$pull": {"presenze": current_day}}
|
||||
)
|
||||
os.kill(os.getpid(), signal.SIGUSR1)
|
||||
#os.kill(os.getpid(), signal.SIGUSR1)
|
||||
self.handler.execute_callbacks('users_update')
|
||||
|
||||
|
||||
@ui.refreshable
|
||||
@@ -86,13 +89,10 @@ class Manager:
|
||||
|
||||
ui.separator()
|
||||
|
||||
def onSignal(signum, frame):
|
||||
print("Signal")
|
||||
tabellaUtenti.refresh()
|
||||
|
||||
signal.signal(signal.SIGUSR1, onSignal)
|
||||
self.handler.register_callback("users_update", tabellaUtenti.refresh)
|
||||
liv = db.livelli.find_one({"id":livello})
|
||||
sed = db.sedi.find_one({"id":sede})
|
||||
|
||||
## FRONTEND
|
||||
with ui.row().classes("w-full"):
|
||||
ui.icon("chevron_left", size="lg").on("click", lambda: ui.open("/"))
|
||||
|
||||
+4
-8
@@ -6,14 +6,14 @@ from montydb.types.objectid import ObjectId
|
||||
|
||||
from fastapi.responses import RedirectResponse
|
||||
|
||||
def main(userid, db):
|
||||
def main(userid, db, handler):
|
||||
collection = db.users
|
||||
|
||||
async def delete_user():
|
||||
result = await dialog
|
||||
if result:
|
||||
db.users.delete_one({"_id":ObjectId(userid)})
|
||||
os.kill(os.getpid(), signal.SIGUSR1)
|
||||
handler.execute_callbacks('users_update')
|
||||
await ui.run_javascript('history.back()', respond=False)
|
||||
|
||||
def register_payment(month, flag):
|
||||
@@ -27,13 +27,8 @@ def main(userid, db):
|
||||
{"_id": ObjectId(userid)},
|
||||
{"$pull": {"pagamenti": month.strftime('%Y-%m-%d %H:%M:%S')}}
|
||||
)
|
||||
os.kill(os.getpid(), signal.SIGUSR1)
|
||||
page.refresh()
|
||||
handler.execute_callbacks('users_update')
|
||||
|
||||
def onSignal(signum, frame):
|
||||
page.refresh()
|
||||
|
||||
signal.signal(signal.SIGUSR1, onSignal)
|
||||
|
||||
# Calculate last start date
|
||||
start_date = datetime(datetime.now().year - (datetime.now().month < 8), 9, 1)
|
||||
@@ -83,6 +78,7 @@ def main(userid, db):
|
||||
ui.button(color="negative", text= "NON PAGATO", on_click= lambda dt=month: register_payment(dt, True)).style('font-size:0.4rem;font-weight:700;white-space: nowrap;')
|
||||
else:
|
||||
ui.button(text= "PAGA", on_click= lambda dt=month: register_payment(dt, True)).style('font-size:0.5rem;font-weight:700;').props('outline')
|
||||
handler.register_callback("users_update", page.refresh)
|
||||
## FRONTEND
|
||||
|
||||
with ui.dialog() as dialog, ui.card():
|
||||
|
||||
+2
-2
@@ -5,7 +5,7 @@ from montydb.types.objectid import ObjectId
|
||||
import signal
|
||||
import os
|
||||
|
||||
def main(db: MontyClient, userid: str, sede: int, livello: int) -> None:
|
||||
def main( userid: str, sede: int, livello: int, db: MontyClient, handler) -> None:
|
||||
|
||||
if userid!= "new":
|
||||
result = db.users.find_one({"_id":ObjectId(userid)})
|
||||
@@ -23,7 +23,7 @@ def main(db: MontyClient, userid: str, sede: int, livello: int) -> None:
|
||||
{"_id": ObjectId(userid)},
|
||||
{"$set": data_submit}
|
||||
)
|
||||
os.kill(os.getpid(), signal.SIGUSR1)
|
||||
handler.execute_callbacks('users_update')
|
||||
await ui.run_javascript('history.back()', respond=False)
|
||||
|
||||
ui.icon("chevron_left", size="lg").on("click", lambda: ui.run_javascript('history.back()', respond=False))
|
||||
|
||||
Reference in New Issue
Block a user