From 716c04126f2fd666de54c5ec7d4fee4dc0bc4913 Mon Sep 17 00:00:00 2001 From: rizwanisready Date: Wed, 8 May 2024 12:26:31 +0530 Subject: [PATCH] principal subscription query 2 --- manage_notifications/api/cron_views.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/manage_notifications/api/cron_views.py b/manage_notifications/api/cron_views.py index d9fdea3..be5d45e 100644 --- a/manage_notifications/api/cron_views.py +++ b/manage_notifications/api/cron_views.py @@ -24,6 +24,11 @@ class OneWeekSubscriptionAlertView(APIView): eligible_principals = self.eligible_principals() for principal in eligible_principals: + try: + player_id = principal.principal.player_id + except AttributeError: + # Handle the case where principal is null or does not have a player_id field + continue notification_title = "Subscription Expiry Reminder" notification_message = "Your subscription is going to expire in a week." notification_category = NotificationCategoryChoices.SUBSCRIPTION @@ -32,7 +37,7 @@ class OneWeekSubscriptionAlertView(APIView): notification_payload = { "headings": {"en": notification_title}, "contents": {"en": notification_message}, - "include_player_ids": [principal.player_id], + "include_player_ids": [player_id], } response = self.client.send_notification(notification_payload)