morozovka-portal/seed_schedule.py

54 lines
2.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from datetime import datetime, timezone, timedelta
from sqlmodel import Session, select
from app.db import engine
from app.models import Event, GlobalStatus
def seed_data():
with Session(engine) as session:
# Обновляем статус
status = session.exec(select(GlobalStatus)).first()
if status:
status.status = "on_place"
status.message = "Провожу пары по расписанию"
status.updated_at = datetime.now(timezone.utc)
session.add(status)
# Добавляем события (относительно текущего времени)
now = datetime.now(timezone.utc)
events = [
Event(
title="Лекция: Введение в веб-разработку",
event_type="lecture",
start_time=now + timedelta(days=1, hours=2),
end_time=now + timedelta(days=1, hours=4),
location="Ауд. 405",
description="Разбираем основы HTTP и клиент-серверной архитектуры."
),
Event(
title="Мастер-класс по пайке",
event_type="workshop",
start_time=now + timedelta(days=2, hours=5),
end_time=now + timedelta(days=2, hours=8),
location="Лаборатория 101",
description="Сборка простого светодиодного индикатора."
),
Event(
title="Встреча с командой Неймарк",
event_type="meeting",
start_time=now + timedelta(days=3, hours=1),
end_time=now + timedelta(days=3, hours=2),
location="Переговорная",
is_public=False
)
]
for e in events:
session.add(e)
session.commit()
print("[+] Тестовые события успешно добавлены в БД!")
if __name__ == "__main__":
seed_data()