from datetime import timedelta from django.utils import timezone from vbv_lernwelt.core.admin import User from vbv_lernwelt.notify.models import NotificationCategory from vbv_lernwelt.notify.tests.factories import NotificationFactory def create_default_notifications() -> int: """ Creates default notifications for all users. @return: The number of created notifications per user. """ avatar_urls = [ "/static/avatars/avatar_alexandra.png", "/static/avatars/avatar_bianca.png", "/static/avatars/avatar_chantal.png", ] timestamps = [timezone.now() - timedelta(hours=n) for n in range(13)] notifications_per_user: int for user in User.objects.all(): notifications_per_user = len( ( NotificationFactory( recipient=user, actor=user, verb="Alexandra hat einen neuen Beitrag erfasst", actor_avatar_url=avatar_urls[0], target_url="/", notification_category=NotificationCategory.USER_INTERACTION, timestamp=timestamps[0], ), NotificationFactory( recipient=user, actor=user, verb="Alexandra hat einen neuen Beitrag erfasst", actor_avatar_url=avatar_urls[0], target_url="/", notification_category=NotificationCategory.USER_INTERACTION, timestamp=timestamps[1], ), NotificationFactory( recipient=user, actor=user, verb="Alexandra hat einen neuen Beitrag erfasst", actor_avatar_url=avatar_urls[0], target_url="/", notification_category=NotificationCategory.USER_INTERACTION, timestamp=timestamps[2], ), NotificationFactory( recipient=user, actor=user, verb="Alexandra hat einen neuen Beitrag erfasst", actor_avatar_url=avatar_urls[0], target_url="/", notification_category=NotificationCategory.USER_INTERACTION, timestamp=timestamps[3], ), NotificationFactory( recipient=user, actor=user, verb="Bianca hat für den Auftrag Autoversicherung 3 eine Lösung abgegeben", actor_avatar_url=avatar_urls[1], target_url="/", notification_category=NotificationCategory.USER_INTERACTION, timestamp=timestamps[4], ), NotificationFactory( recipient=user, actor=user, verb="Bianca hat für den Auftrag Autoversicherung 1 eine Lösung abgegeben", actor_avatar_url=avatar_urls[1], target_url="/", notification_category=NotificationCategory.USER_INTERACTION, timestamp=timestamps[5], ), NotificationFactory( recipient=user, actor=user, verb="Bianca hat für den Auftrag Autoversicherung 2 eine Lösung abgegeben", actor_avatar_url=avatar_urls[1], target_url="/", notification_category=NotificationCategory.USER_INTERACTION, timestamp=timestamps[6], ), NotificationFactory( recipient=user, actor=user, verb="Bianca hat für den Auftrag Autoversicherung 4 eine Lösung abgegeben", actor_avatar_url=avatar_urls[1], target_url="/", notification_category=NotificationCategory.USER_INTERACTION, timestamp=timestamps[7], ), NotificationFactory( recipient=user, actor=user, verb="Chantal hat eine Bewertung für den Transferauftrag 3 eingegeben", target_url="/", actor_avatar_url=avatar_urls[2], notification_category=NotificationCategory.USER_INTERACTION, timestamp=timestamps[8], ), NotificationFactory( recipient=user, actor=user, verb="Chantal hat eine Bewertung für den Transferauftrag 4 eingegeben", target_url="/", actor_avatar_url=avatar_urls[2], notification_category=NotificationCategory.USER_INTERACTION, timestamp=timestamps[9], ), NotificationFactory( recipient=user, actor=user, verb="Super, du kommst in deinem Lernpfad gut voran. Schaue dir jetzt die verfügbaren Prüfungstermine an.", target_url="/", notification_category=NotificationCategory.PROGRESS, timestamp=timestamps[10], ), NotificationFactory( recipient=user, actor=user, verb="Wartungsarbeiten: 20.12.2022 08:00 - 12:00", notification_category=NotificationCategory.INFORMATION, timestamp=timestamps[11], ), NotificationFactory( recipient=user, actor=user, verb="Wartungsarbeiten: 31.01.2023 08:00 - 12:00", notification_category=NotificationCategory.INFORMATION, timestamp=timestamps[12], ), ) ) return notifications_per_user