changes to the Username displayment

This commit is contained in:
2026-11-02 14:59:57 +01:00
parent 3afec10346
commit 58dd957315
+17
View File
@@ -180,6 +180,23 @@ def _display_username(user_value):
if user_doc:
return str(user_doc.get('Username') or user_doc.get('username') or lookup_value)
client = None
try:
client = MongoClient(MONGODB_HOST, MONGODB_PORT)
cards = get_tenant_db(client)['student_cards']
card_queries = [{'AusweisId': lookup_value} for lookup_value in lookup_values]
if ObjectId.is_valid(raw_value):
card_queries.insert(0, {'_id': ObjectId(raw_value)})
card = cards.find_one({'$or': card_queries}) if card_queries else None
if card:
card = _decrypt_student_card_doc(card)
card_name = str(card.get('SchülerName') or '').strip()
if card_name:
return card_name
finally:
if client:
client.close()
return str(decrypted_value or raw_value)