dynamic appointments loading

This commit is contained in:
2025-06-14 15:08:43 +00:00
parent 4738740292
commit 2e8c852ee6
10 changed files with 187 additions and 52 deletions

View File

@@ -3,7 +3,7 @@ from sqlalchemy.orm import sessionmaker
from models import Event, EventMedia, EventType
from dotenv import load_dotenv
import os
from datetime import datetime, timedelta, timezone
from datetime import datetime, timedelta
# .env laden
load_dotenv()
@@ -32,7 +32,7 @@ session.query(Event).filter_by(client_uuid=client_uuid).delete()
session.commit()
# --- Ende Löschungen ---
now = datetime.now(timezone.utc)
now = datetime.now()
events = [
Event(
@@ -48,10 +48,10 @@ events = [
),
Event(
client_uuid=client_uuid,
title="Webseite: Schulhomepage",
description="Zeigt die Schulhomepage an.",
start=now + timedelta(days=1, hours=10),
end=now + timedelta(days=1, hours=11),
title="Schulwebsite Update",
description="Neue Inhalte auf der Schulwebsite.",
start=now + timedelta(days=2, hours=10),
end=now + timedelta(days=2, hours=11),
event_type=EventType.website,
created_by=created_by,
updated_by=None,
@@ -59,10 +59,10 @@ events = [
),
Event(
client_uuid=client_uuid,
title="Video: Sicherheitsunterweisung",
description="Video zur Sicherheit im Chemieunterricht.",
start=now + timedelta(days=2, hours=8),
end=now + timedelta(days=2, hours=8, minutes=30),
title="Lehrvideo ansehen",
description="Video zum Thema Photosynthese.",
start=now + timedelta(days=3, hours=9),
end=now + timedelta(days=3, hours=10),
event_type=EventType.video,
created_by=created_by,
updated_by=None,
@@ -70,10 +70,10 @@ events = [
),
Event(
client_uuid=client_uuid,
title="Nachricht: Vertretungsplan",
description="Aktuelle Vertretungen werden angezeigt.",
start=now + timedelta(days=2, hours=9),
end=now + timedelta(days=2, hours=9, minutes=15),
title="Nachricht vom Lehrer",
description="Wichtige Mitteilung zum Unterricht.",
start=now + timedelta(days=4, hours=13),
end=now + timedelta(days=4, hours=14),
event_type=EventType.message,
created_by=created_by,
updated_by=None,
@@ -81,10 +81,65 @@ events = [
),
Event(
client_uuid=client_uuid,
title="WebUntis Stundenplan",
description="Automatisch importierter Stundenplan.",
start=now + timedelta(days=3, hours=7),
end=now + timedelta(days=3, hours=8),
title="Sonstiges Event",
description="Allgemeines Event ohne Kategorie.",
start=now + timedelta(days=5, hours=11),
end=now + timedelta(days=5, hours=12),
event_type=EventType.other,
created_by=created_by,
updated_by=None,
is_active=True
),
Event(
client_uuid=client_uuid,
title="WebUntis Termin",
description="Termin aus WebUntis importiert.",
start=now + timedelta(days=6, hours=8),
end=now + timedelta(days=6, hours=9),
event_type=EventType.webuntis,
created_by=created_by,
updated_by=None,
is_active=True
),
Event(
client_uuid=client_uuid,
title="Englisch Präsentation",
description="Präsentation zu Shakespeare.",
start=now + timedelta(days=8, hours=10),
end=now + timedelta(days=8, hours=11),
event_type=EventType.presentation,
created_by=created_by,
updated_by=None,
is_active=True
),
Event(
client_uuid=client_uuid,
title="Website Relaunch",
description="Vorstellung der neuen Schulwebsite.",
start=now + timedelta(days=10, hours=9),
end=now + timedelta(days=10, hours=10),
event_type=EventType.website,
created_by=created_by,
updated_by=None,
is_active=True
),
Event(
client_uuid=client_uuid,
title="Videoanalyse",
description="Analyse eines Lehrvideos.",
start=now + timedelta(days=12, hours=14),
end=now + timedelta(days=12, hours=15),
event_type=EventType.video,
created_by=created_by,
updated_by=None,
is_active=True
),
Event(
client_uuid=client_uuid,
title="WebUntis Info",
description="Weitere Termine aus WebUntis.",
start=now + timedelta(days=14, hours=8),
end=now + timedelta(days=14, hours=9),
event_type=EventType.webuntis,
created_by=created_by,
updated_by=None,
@@ -92,10 +147,12 @@ events = [
),
]
session.add_all(events)
session.commit()
# Events anlegen und speichern
for event in events:
session.add(event)
session.commit() # Jetzt haben alle Events eine ID
# EventMedia zuordnen (IDs müssen jetzt existieren)
# EventMedia mit den richtigen event_id-Werten anlegen
event_media = [
EventMedia(
event_id=events[0].id,
@@ -106,32 +163,60 @@ event_media = [
EventMedia(
event_id=events[1].id,
media_type=EventType.website,
url="https://schule.example.com",
url="https://schule.example.com/update",
order=1
),
EventMedia(
event_id=events[2].id,
media_type=EventType.video,
url="https://videos.example.com/sicherheit.mp4",
order=1,
autoplay=True,
loop=False,
volume=0.8
url="https://example.com/photosynthese-video.mp4",
order=1
),
EventMedia(
event_id=events[3].id,
media_type=EventType.message,
url="https://schule.example.com/vertretungsplan",
url="https://example.com/lehrer-nachricht",
order=1
),
EventMedia(
event_id=events[4].id,
media_type=EventType.other,
url="https://example.com/sonstiges-event.pdf",
order=1
),
EventMedia(
event_id=events[5].id,
media_type=EventType.webuntis,
url="https://webuntis.example.com/stundenplan",
url="https://webuntis.example.com/termin",
order=1
),
EventMedia(
event_id=events[6].id,
media_type=EventType.presentation,
url="https://example.com/praesentation-englisch.pdf",
order=1
),
EventMedia(
event_id=events[7].id,
media_type=EventType.website,
url="https://schule.example.com/relaunch",
order=1
),
EventMedia(
event_id=events[8].id,
media_type=EventType.video,
url="https://example.com/videoanalyse.mp4",
order=1
),
EventMedia(
event_id=events[9].id,
media_type=EventType.webuntis,
url="https://webuntis.example.com/info",
order=1
),
]
session.add_all(event_media)
for media in event_media:
session.add(media)
session.commit()
print("Test-Events und EventMedia wurden angelegt.")