Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e2aeea46f9 | |||
| 865fddd45b | |||
| 1835195d2f |
@@ -265,7 +265,9 @@ def remove_done():
|
|||||||
|
|
||||||
|
|
||||||
def get_upcoming_for_user(user: str, limit: int = 25):
|
def get_upcoming_for_user(user: str, limit: int = 25):
|
||||||
"""Return upcoming appointment plans for a user, matching by encrypted username."""
|
"""
|
||||||
|
Return upcoming appointment plans for a user, handling encrypted database records.
|
||||||
|
"""
|
||||||
try:
|
try:
|
||||||
if hasattr(globals(), 'remove_done'):
|
if hasattr(globals(), 'remove_done'):
|
||||||
remove_done()
|
remove_done()
|
||||||
@@ -279,22 +281,26 @@ def get_upcoming_for_user(user: str, limit: int = 25):
|
|||||||
items = db['appointments']
|
items = db['appointments']
|
||||||
|
|
||||||
today = datetime.date.today().strftime('%Y-%m-%d')
|
today = datetime.date.today().strftime('%Y-%m-%d')
|
||||||
|
target_user = str(user or '').strip()
|
||||||
encrypted_user = dp.encrypt_text(str(user or '').strip())
|
|
||||||
|
|
||||||
cursor = items.find(
|
cursor = items.find(
|
||||||
_active_record_query(
|
_active_record_query({
|
||||||
{
|
|
||||||
'user': encrypted_user,
|
|
||||||
'date_end': {'$gte': today},
|
'date_end': {'$gte': today},
|
||||||
}
|
})
|
||||||
)
|
|
||||||
).sort('date_start', 1)
|
).sort('date_start', 1)
|
||||||
|
|
||||||
results = []
|
results = []
|
||||||
for item in cursor:
|
for item in cursor:
|
||||||
item['_id'] = str(item.get('_id'))
|
decrypted_item = _decrypt_appointment(item)
|
||||||
results.append(_decrypt_appointment(item))
|
if not decrypted_item:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if decrypted_item.get('user', '').strip() != target_user:
|
||||||
|
continue
|
||||||
|
|
||||||
|
decrypted_item['_id'] = str(decrypted_item.get('_id'))
|
||||||
|
results.append(decrypted_item)
|
||||||
|
|
||||||
if len(results) >= max(1, int(limit)):
|
if len(results) >= max(1, int(limit)):
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|||||||
@@ -374,6 +374,7 @@ def main():
|
|||||||
upcoming_events = appointment_service.get_user_upcoming_events(current_user) if current_user else []
|
upcoming_events = appointment_service.get_user_upcoming_events(current_user) if current_user else []
|
||||||
tenant_id = _current_tenant_id()
|
tenant_id = _current_tenant_id()
|
||||||
|
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
'terminplaner.html',
|
'terminplaner.html',
|
||||||
school_periods=cfg.SCHOOL_PERIODS,
|
school_periods=cfg.SCHOOL_PERIODS,
|
||||||
|
|||||||
Reference in New Issue
Block a user