changes in tracking subscription

This commit is contained in:
Flatlogic Bot 2026-01-24 04:23:11 +00:00
parent 221476cb52
commit 4cbc936312
4 changed files with 28 additions and 1 deletions

View File

@ -11,6 +11,8 @@ from django.db.models import Q
from django.contrib.auth.models import User from django.contrib.auth.models import User
from .whatsapp import send_whatsapp_message from .whatsapp import send_whatsapp_message
from django.contrib.auth.forms import AuthenticationForm from django.contrib.auth.forms import AuthenticationForm
from django.core.mail import send_mail
from django.conf import settings
import json import json
def home(request): def home(request):
@ -492,6 +494,25 @@ def renew_subscription(request):
profile.subscription_expiry = timezone.now().date() + timedelta(days=365) profile.subscription_expiry = timezone.now().date() + timedelta(days=365)
profile.save() profile.save()
# Notifications
expiry_date = profile.subscription_expiry.strftime('%Y-%m-%d')
msg = _("Your subscription for MASAR CARGO has been successfully renewed! Your new expiry date is %(date)s. Thank you for using our service.") % {"date": expiry_date}
# WhatsApp
if profile.full_phone_number:
send_whatsapp_message(profile.full_phone_number, msg)
# Email
if request.user.email:
send_mail(
_("Subscription Renewed - MASAR CARGO"),
msg,
settings.DEFAULT_FROM_EMAIL,
[request.user.email],
fail_silently=True,
)
messages.success(request, _("Subscription renewed successfully!")) messages.success(request, _("Subscription renewed successfully!"))
return redirect('dashboard') return redirect('dashboard')
return redirect('subscription_expired') return redirect('subscription_expired')

Binary file not shown.

View File

@ -1455,3 +1455,9 @@ msgstr "لمواصلة استخدام خدماتنا، يرجى تجديد اش
msgid "Contact for Renewal" msgid "Contact for Renewal"
msgstr "الاتصال للتجديد" msgstr "الاتصال للتجديد"
msgid "Your subscription for MASAR CARGO has been successfully renewed! Your new expiry date is %(date)s. Thank you for using our service."
msgstr "تم تجديد اشتراكك في مسار للشحن بنجاح! تاريخ انتهاء اشتراكك الجديد هو %(date)s. شكراً لاستخدامك خدمتنا."
msgid "Subscription Renewed - MASAR CARGO"
msgstr "تم تجديد الاشتراك - مسار للشحن"