diff --git a/core/__pycache__/views.cpython-311.pyc b/core/__pycache__/views.cpython-311.pyc index e5fe7c7..8e87872 100644 Binary files a/core/__pycache__/views.cpython-311.pyc and b/core/__pycache__/views.cpython-311.pyc differ diff --git a/core/views.py b/core/views.py index 0b8a4b9..8ee03a0 100644 --- a/core/views.py +++ b/core/views.py @@ -11,6 +11,8 @@ from django.db.models import Q from django.contrib.auth.models import User from .whatsapp import send_whatsapp_message from django.contrib.auth.forms import AuthenticationForm +from django.core.mail import send_mail +from django.conf import settings import json def home(request): @@ -492,6 +494,25 @@ def renew_subscription(request): profile.subscription_expiry = timezone.now().date() + timedelta(days=365) 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!")) return redirect('dashboard') - return redirect('subscription_expired') \ No newline at end of file + return redirect('subscription_expired') diff --git a/locale/ar/LC_MESSAGES/django.mo b/locale/ar/LC_MESSAGES/django.mo index 3000531..98ad9ea 100644 Binary files a/locale/ar/LC_MESSAGES/django.mo and b/locale/ar/LC_MESSAGES/django.mo differ diff --git a/locale/ar/LC_MESSAGES/django.po b/locale/ar/LC_MESSAGES/django.po index 6143ff4..efb1d72 100644 --- a/locale/ar/LC_MESSAGES/django.po +++ b/locale/ar/LC_MESSAGES/django.po @@ -1455,3 +1455,9 @@ msgstr "لمواصلة استخدام خدماتنا، يرجى تجديد اش msgid "Contact for Renewal" 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 "تم تجديد الاشتراك - مسار للشحن"