@@ -1,11 +1,11 @@
|
||||
from django.conf import settings
|
||||
from django.db import transaction
|
||||
import requests
|
||||
from django.shortcuts import get_object_or_404
|
||||
from datetime import timedelta
|
||||
from django.utils import timezone
|
||||
from onesignal_sdk.client import Client as OneSignalClient
|
||||
from accounts.models import IAmPrincipal, IAmPrincipalOtp, IAmPrincipalType
|
||||
from manage_notifications.models import InAppNotification, NotificationCategoryChoices
|
||||
from manage_notifications.models import IAmPrincipalNotificationSettings, InAppNotification, NotificationCategoryChoices
|
||||
from manage_referrals.models import (
|
||||
GoodTimeCoins,
|
||||
ReferralRecord,
|
||||
@@ -71,11 +71,22 @@ class NotificationService:
|
||||
|
||||
def payment_failed_notification(self, principal, subscription, amount):
|
||||
print("payment_failed_notification: ", principal.player_id)
|
||||
if not self.should_send_referral_notification(principal):
|
||||
print("Referral notifications are disabled for this user")
|
||||
return
|
||||
title = "Payment Failed!"
|
||||
message = f"Your payment for {subscription} of ${amount} was failed."
|
||||
self.send_notification(title, message, principal.player_id)
|
||||
self.save_notification(principal, title, message, NotificationCategoryChoices.TRANSACTION)
|
||||
|
||||
def should_send_referral_notification(self, principal):
|
||||
notification_settings = get_object_or_404(
|
||||
IAmPrincipalNotificationSettings,
|
||||
principal=principal,
|
||||
notification_category=NotificationCategoryChoices.REFERRAL,
|
||||
)
|
||||
return notification_settings.is_enabled
|
||||
|
||||
|
||||
class WebhookService:
|
||||
def __init__(self, webhook_data):
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
from django.db.models import Count, Q
|
||||
from django.utils import timezone
|
||||
from datetime import timedelta
|
||||
from reportlab.pdfgen import canvas
|
||||
from reportlab.lib.pagesizes import letter
|
||||
from reportlab.graphics.shapes import Drawing
|
||||
from reportlab.lib import colors
|
||||
@@ -143,7 +142,7 @@ def generate_event_report_pdf_three(user, report_data):
|
||||
organiser_name = Paragraph(
|
||||
f"Name of the Organiser - {user.get_full_name()}", styles["Title"]
|
||||
)
|
||||
contact_name = Paragraph(f"Contact Name - {user.email}", styles["Title"])
|
||||
contact_email = Paragraph(f"Contact Email - {user.email}", styles["Title"])
|
||||
|
||||
elements.extend(
|
||||
[
|
||||
@@ -153,7 +152,7 @@ def generate_event_report_pdf_three(user, report_data):
|
||||
Spacer(1, 12),
|
||||
organiser_name,
|
||||
Spacer(1, 12),
|
||||
contact_name,
|
||||
contact_email,
|
||||
Spacer(1, 72), # Add space before the logo
|
||||
]
|
||||
)
|
||||
@@ -161,8 +160,8 @@ def generate_event_report_pdf_three(user, report_data):
|
||||
# Insert company logo
|
||||
logo_path = os.path.join("static", "images", "icon.png") # Path to the logo
|
||||
logo = Image(logo_path)
|
||||
logo.drawWidth = 300 # Adjust the width as needed
|
||||
logo.drawHeight = 150 # Adjust the height as needed
|
||||
logo.drawWidth = 150 # Adjust the width as needed
|
||||
logo.drawHeight = 300 # Adjust the height as needed
|
||||
logo.hAlign = "CENTER" # Center the logo
|
||||
|
||||
elements.append(logo)
|
||||
@@ -290,15 +289,6 @@ def generate_event_report_pdf_three(user, report_data):
|
||||
elements.append(Paragraph(interested, custom_style))
|
||||
elements.append(Paragraph(going, custom_style))
|
||||
elements.append(Paragraph(reviews, custom_style))
|
||||
elements.append(Spacer(1, 12))
|
||||
|
||||
# location_details = []
|
||||
# for location, count in event["locations"].items():
|
||||
# location_details.append(f"{location}: {count}")
|
||||
|
||||
# elements.append(Paragraph("Event viewed from:", custom_style))
|
||||
# elements.append(Paragraph(", ".join(location_details), custom_style))
|
||||
# elements.append(PageBreak())
|
||||
elements.append(Spacer(1, 48))
|
||||
|
||||
pie_data = [
|
||||
|
||||
Reference in New Issue
Block a user